template-engine

What is the fastest template system for Python?

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:59:50
问题 Jinja2 and Mako are both apparently pretty fast. How do these compare to (the less featured but probably good enough for what I'm doing) string.Template ? 回答1: Here are the results of the popular template engines for rendering a 10x1000 HTML table. Python 2.6.2 on a 3GHz Intel Core 2 Kid template 696.89 ms Kid template + cElementTree 649.88 ms Genshi template + tag builder 431.01 ms Genshi tag builder 389.39 ms Django template 352.68 ms Genshi template 266.35 ms ElementTree 180.06 ms

Good Javascript template engine to work with JSON

一个人想着一个人 提交于 2019-11-27 04:40:36
问题 I have looked at jTemplates and it's worth a try. Are there any other template engines other than jTemplates? 回答1: I liked the approach the JavaScriptMVC Frameworks Views take, especially because it uses JavaScript itself as the templating language. The framework is now based on jQuery and you can render your Model right into the views (Model supports JSON, JSONP, XML etc.). 回答2: Did you try pure.js ? The main difference with the dozens of JS templating engines available is that PURE leaves

How do I use Django templates without the rest of Django?

痞子三分冷 提交于 2019-11-27 02:31:28
I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO_SETTINGS_MODULE environment variable? If I run the following code: >>> import django.template >>> from django.template import Template, Context >>> t = Template('My name is {{ my_name }}.') I get: ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. The solution is simple. It's actually well documented , but not too easy to find. (I had to dig

How do I pass node.js server variables into my angular/html view?

半腔热情 提交于 2019-11-27 02:15:12
问题 I have this route in my app.js file that starts the server app.get('/view/:item_id', function(req,res){ var A = 5; res.render('view_item'); and I have this in my view_item.html: <p>{{A}}</p> I want it to display the variable value - 5. If I were using a template engine such as jade it would be easy. I could change that third line of my server code to res.render({A:A},'view_item'); But I am using html as my template engine. My research so far has told me that using a template engine with

Play! framework: define a variable in template? [duplicate]

大憨熊 提交于 2019-11-27 01:20:32
问题 This question already has an answer here: Declare variable in a Play2 scala template 8 answers I'm passing to a template an Event object and what I need to do is checking @event.getSeverity value. if the value is positive, I want to color a specific <div> in green. if the value is negative I want to color a specific <div> in red. I couldn't find a way to define a variable. is it possible? it should be I think. anyhow, what's the simplest way accomplishing this? thanks 回答1: As stated in the

Declare CSS style outside the “HEAD” element of an “HTML” page?

对着背影说爱祢 提交于 2019-11-27 00:13:14
问题 my use-case is the following : I'm composing an HTML page by using parts that are valid HTML fragments but not valid pages, like Divs ; these elements are using CSS to manage their style. I'd like to allow each fragment to be responsible for its own styling requirements and to not rely on the declarations of style-sheets in the main fragment (the one with the "HTML" tag). So here come the question : is there any (standard) way to add some CSS styling outside the HEAD element (excluding the

How to create global variables accessible in all views using Express / Node.JS?

走远了吗. 提交于 2019-11-26 23:35:46
Ok, so I have built a blog using Jekyll and you can define variables in a file _config.yml which are accessible in all of the templates/layouts. I am currently using Node.JS / Express with EJS templates and ejs-locals (for partials/layouts. I am looking to do something similar to the global variables like site.title that are found in _config.yml if anyone is familiar with Jekyll. I have variables like the site's title, (rather than page title), author/company name, which stay the same on all of my pages. Here is an example of what I am currently doing.: exports.index = function(req, res){ res

Escape double braces {{ … }} in Mustache template. (templating a template in NodeJS)

别来无恙 提交于 2019-11-26 22:45:24
问题 I'm trying to template a template, like below: {{{ { "name" : "{{name}}", "description" : "{{description}}" } }}} {{{debug this}}} <h1>{{name}}</h1> Where I want to triple brackets to stay, but double brackets to be replaced with the JSON passed in. Anyone know the best way to do this without writing post-process JS code, and if not, is there a good nodeJS template engine for this type of scenario? 回答1: You can switch delimiters to something that won't conflict with the triple mustaches, like

Why should I use templating system in PHP?

こ雲淡風輕ζ 提交于 2019-11-26 19:37:51
Why should I use templating system in PHP? The reasoning behind my question is: PHP itself is feature rich templating system, why should I install another template engine? The only two pros I found so far are: A bit cleaner syntax (sometimes) Template engine is not usually powerful enough to implement business logic so it forces you to separate concerns. Templating with PHP can lure you to walk around the templating principles and start writing code soup again. ... and both are quite negligible when compared to cons. Small example: PHP <h1><?=$title?></h1> <ul> <? foreach ($items as $item) {?>

C++ HTML template framework, templatizing library, HTML generator library [closed]

不问归期 提交于 2019-11-26 19:25:00
I am looking for template/generator libraries for C++ that are similar to eg. Ruby's Erb, Haml, PHP's Smarty, etc. It would be great if I it would sport some basic features like loops, if/else, int conversion to strings, etc. Parameter passing to template rendering engine is also important if I could pass all of them in a hash map instead of calling some function for each of parameters. Do you have any recommendations? I can see also the possibility of embedding languages like Lua, however I haven't found a templatizing library for that either. rogerz A quick review of the mentioned project.