如何在SWIG视图中呈现html express.js?
我在MySQL列中有一个html代码数据,然后我在视图上调用它(使用swig视图模块)。 如何显示它很像一个HTML代码在视图中?
server.js
app.engine('html', swig.renderFile); app.set('view engine', 'html'); app.set('views', __dirname + '/views');
controller.js
newsExports.insertNews(title, content, dateadded, validpercent, basetitle, function(news){ res.render('index/news', {news: news}); })
view.html
{% for i in news %} {{i.content}} {% endfor %}
这是答案: http : //paularmstrong.github.io/swig/docs/filters/
使用{{i.content|safe}}
或{%raw%} {{i.content}}{%endraw%}
它的作品就像一个魅力!
- 如何在NodeJS / Express API中创build多个asynchronous标注
- 如何在MongoDB地理空间中select查询中的字段?
- app.use(express.static(path.join(__ dirname,'public'))); ReferenceError:path没有定义是什么问题?
- expressjs修改/添加模块中的对象属性
- 新来expression,我从哪里开始?
- 执行路由器时出错
- 如何使用dynamic助手重写express.js中的Flash消息?
- iPhone / Android不会解雇用DNS实现的wifi登陆页面
- NodeJS – 所有短(缩写)的字到全字的特征模块