0.1.13 • Published 9 years ago
rapunzel v0.1.13
rapunzel
![Dependency Status]()
This lightweight module simplifies the process of generating code strings
Install
$ npm install --save rapunzel
Usage
var rapunzel = require('rapunzel');
var h_obj = {
"example":
{
"of": "stringifying a simple object",
"that": "only has objects and strings",
}
};
var stringify_obj = function(add, h_part) {
if('string' === typeof h_part) {
add("'"+h_part.replace(/'/g, "\\'")+"'", true);
}
else {
add.open('{', ',', true);
for(var s_property in h_part) {
add(s_property+': ');
stringify_obj(add, h_part[s_property]);
}
add.close('}');
}
};
var k_builder = rapunzel({
preamble: function(add) {
add('// this is the beginning');
},
body: function(add) {
stringify_obj(add, h_obj);
},
closing: function(add) {
add('// this is the end');
},
});
k_builder.produce({
indent: '\t',
});
yields:
// this is the beginning
{
example: {
of: 'stringifying a simple object',
that: 'only has objects and strings',
},
}
// this is the end
License
ISC © Blake Regalia
0.1.13
9 years ago
0.1.12
9 years ago
0.1.11
9 years ago
0.1.10
9 years ago
0.1.9
9 years ago
0.1.8
10 years ago
0.1.7
10 years ago
0.1.6
10 years ago
0.1.5
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago