How to use the render function from swig

Find comprehensive JavaScript swig.render code examples handpicked from public code repositorys.

31
32
33
34
35
36
37
38
39
40
41
42


  return compile.join('\n');
}, forTag.ends, true);


function swigRenderer(data, locals) {
  return swig.render(data.text, {
    locals,
    filename: data.path,
  });
}
fork icon3
star icon3
watch icon0

+ 3 other calls in file

104
105
106
107
108
109
110
111
112
113

if (metadatas.length) {
        // console.log(metadatas)
        headerFile = swig.render(headerTemplate, {locals:{items:metadatas}});
        //console.log(headerFile);
        impFile = swig.render(impTemplate, {locals:{items:metadatas}})
        //console.log(impFile);
        fs.writeFileSync(path.normalize('orm.h'), headerFile)
        fs.writeFileSync(path.normalize('orm.m'), impFile)      
};
fork icon0
star icon3
watch icon3

+ 3 other calls in file

118
119
120
121
122
123
124
125
126
var locals = {
  _root: page_relative_path,
  _uri: uri
};
locals = _.assign(data.data, locals);
var content = swig.render(temp, {
  locals: locals,
  filename: path.join(config.dir._root, encodeURIComponent(data.path))
});
fork icon1
star icon0
watch icon0

3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
* @example
* var swig = require('swig');
* var myswig = new swig.Swig({varControls: ['<%=', '%>']});
* myswig.render('Tacos are <%= tacos =>!', { locals: { tacos: 'delicious' }});
* // => Tacos are delicious!
* swig.render('Tacos are <%= tacos =>!', { locals: { tacos: 'delicious' }});
* // => 'Tacos are <%= tacos =>!'
*
* @param  {SwigOpts} [opts={}] Swig options object.
* @return {object}      New Swig environment.
fork icon0
star icon1
watch icon0

+ 3 other calls in file

94
95
96
97
98
99
100
101
102
}
//console.log(swig.render(args[2] +'-t'));
//console.log(swig.compile(args[2] +'-t'));
//var path = args[0].replace(/'/, '').replace(/'/, '');
//var url = args[1].replace(/'/, '').replace(/'/, '');
//console.log('compiler', swig.render('{{routes}}'))
//console.log('compiler', parents)
//options.valuee = 'gaga';
//content[1]['valuee'] = function(){return 'adf'};
fork icon0
star icon0
watch icon0

+ 6 other calls in file