Tag: swig template

如何在swig模板中创build多行stringvariables?

我试图在swig中创build一个多行stringvariables: {% set myVariable = " multi line string " %} 然后我login它: {% logMyVariable(myVariable) %} 但我不明白为什么我的variables不显示在几行: multi line string 而我期待: multi line string 你知道我该怎么做吗?

用合并设置swig选项

我目前使用swig与巩固,它工作正常: app.engine('server.view.html', consolidate['swig']); 现在,我想调整swig选项 ,例如更改autoescaping的默认值。 任何想法,我怎么能做到这一点?

debuggingswig模板引擎,nodejs

是否有任何方法来debuggingswig模板引擎的node.js,因为我没有得到在某些情况下发生错误的确切文件,例如 {% set temp = JSON.parse('some random string') %} 这是我在上面的控制台中得到的: 2015-08-13T09:38:12.254Z – error: SyntaxError: Unexpected token s at Object.parse (native) at Object.eval [as tpl] (eval at <anonymous> (/home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:498:13), <anonymous>:6:810) at compiled (/home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:619:18) at Object.eval [as tpl] (eval at <anonymous> (/home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:498:13), <anonymous>:27:611) at compiled (/home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:619:18) at /home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:559:20 at /home/saurabh/intl/via_node/node_modules/swig/lib/swig.js:690:9 at fs.js:268:14 at Object.oncomplete (fs.js:107:15) 没有提及发生错误的模板文件。

冲突的JavaScript模板

我正在使用Swig模板在Node.js + Express.js上编写项目。 在用户端使用模板系统doT.js 在浏览器中出现这样一个问题: <h1> string {{= it.stringVar}} </ h1> 但我不知道如何使Swig不作为stringvariables的一部分(即不处理大括号)处理。 有没有解决我的问题的机制? 提前致谢!

Gulp.js – 观察并编译swig.js模板文件

我被困在看着我的Swig.js html模板并在每次更改时编译它们的问题,我使用了Gulp.js任务运行器。 这是我的gulpfile.js : var gulp = require('gulp'); var myth = require('gulp-myth'); var swig = require('gulp-swig'); var nodemon = require('gulp-nodemon'); gulp.task('styles', function () { gulp.src('./myth/*.css') .pipe(myth()) .pipe(gulp.dest('./client/css')); }); gulp.task('templates', function () { gulp.src('./views/*.html') .pipe(swig({ load_json: true })) .pipe(gulp.dest('./client')); }); gulp.task('server', function () { gulp.run('styles'); gulp.run('templates'); gulp.src('./server.js').pipe(nodemon()); gulp.watch('./myth/*.css', function () { gulp.run('styles'); }); gulp.watch('./views/*.html', function () […]

无法在Express中呈现swig模板

所以我试图用consolidate.js来渲染swig模板 ,但是当我尝试从另一个模板“扩展”一个模板时,出现以下错误: Error: ENOENT, no such file or directory '//one.html 在我的app.js文件中,我将swig设置为渲染引擎(仅包含相关代码): var consolidate = require('consolidate'); app.set('view engine', 'html'); app.set('views', __dirname + '/views'); app.engine('.html', consolidate.swig); app.get('/test', function(req, res) { res.render('two'); }); 我有一个基本的模板, one.html : <h3>My Site</h3> {% block content %} Welcome {% endblock %} 然后是一个inheritance模板two.html : {% extends 'one.html' %} {% block content %} This is […]

如何在nodejs中使用swig输出JSON

我试过JSONfilter,但我得到“JSON”filter没有find错误。 我在做什么错了? Error: Filter "json" not found at Object.exports.wrapFilter (……./node_modules/swig/lib/helpers.js:310:11) <script type="text/javascript"> {{ places|json }} </script> 对象从mongodb传递 this.displayMainPage = function(req, res, next) { "use strict"; places.getPlaces(10, function(err, results) { "use strict"; if (err) return next(err); return res.render('places_template', { places: results }); }); } 编辑:我试图输出json传递给谷歌地图,并在HTML中显示相同的数据

在AngularJS的Swig模板中转义双括号{{}}

Swig模板和AngularJS都使用双花括号 。 Swig for Angular如何才能避免双重缠绕?