简体   繁体   English

将ustust.js模板编译到HTML服务器端?

[英]Compiling dust.js template to html server side?

Is it possible to compile dust.js template to plain html? 是否可以将dust.js模板编译为纯HTML?

I tried dusty and dustc serverside compilers but they generates a javascript file which will write the content of the template on the page. 我尝试了尘土飞扬的服务器端编译器,但它们生成了一个javascript文件,该文件将在页面上写入模板的内容。

Dust only compiles to JavaScript, but you can use a compiled template to render plain HTML. 灰尘只能编译为JavaScript,但是您可以使用编译后的模板来呈现纯HTML。 This works the same on the server and on the client. 这在服务器和客户端上均相同。 On the server you need to use Node.js or Rhino (or some other engine that interprets JavaScript). 在服务器上,您需要使用Node.js或Rhino(或其他解释JavaScript的引擎)。

It is possible to render a dust template directly to HTML, but it is not recommended. 可以直接将尘土模板呈现为HTML,但不建议这样做。 Anyway, this can be done with pyv8 a Python bindings for V8 JS engine. 无论如何,可以使用pyv8(用于V8 JS引擎的Python绑定)完成此操作。 In this article Andrew Wilkinson show how he made it for mustache.js. 本文中, Andrew Wilkinson展示了他是如何为mustache.js制作的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM