template-engine

Smarty benchmark, anyone?

大城市里の小女人 提交于 2019-12-18 23:38:10
问题 I am considering Smarty as my web app templating solution, and I am now concerned with its performance against plain PHP. The Smarty site says it should be the same, however, I was not able to find anyone doing real benchmarking to prove the statement right or wrong. Did anyone do some benchmarking of Smarty vs plain PHP? Or maybe come across some resources on such tests? Thanks 回答1: Because in the end, Smarty compiles and caches the templates files to native PHP-code, there is indeed no

Import javascript files with jinja from static folder [duplicate]

那年仲夏 提交于 2019-12-18 15:54:55
问题 This question already has answers here : Link to Flask static files with url_for (2 answers) Pass parameter with Python Flask in external Javascript (2 answers) Closed 2 years ago . I need to have access to jinja template in javascript files (due to i18n tags). So the way that i found is just load the js file with include, from the jinja method. {% include "file.js" %} However this method will look for files only in templates folder. But the js files must be in the static folder. My question

Cross Java and Javascript Template Language?

五迷三道 提交于 2019-12-18 13:19:32
问题 There seem to be a lot of template languages for both Java (e.g. JSP, JSTL, Freemarker, Velocity, ...) and for Javascript (e.g. Mustache, Ext's XTemplate, Jquery templates, ...) but is there one which have an implementation for both? Ideally I'd like to be able to have an template which can be evaluated either on the server or on the client side without too much hassle switching over. 回答1: Google Closure/Soy templates. The Wikipedia Page for Web Templating Languages reveals another one:

T4 template and run-time parameters

六眼飞鱼酱① 提交于 2019-12-18 11:57:35
问题 I am building a plug-in in VS 2010 and I get stuck at the T4 generation. Right now I have implemented (like MSDN suggests) a custom T4 host to generate my T4 results and I use it in this way: const string content = @"c:\Simple.tt"; var engine = new Engine(); var host = new MyTemplateHost(); var result = engine.ProcessTemplate(File.ReadAllText(content), host); foreach (CompilerError error in host.Errors) { Console.WriteLine(error.ErrorText); } This works until I pass a parameter in the

Which templating engine can I use with both JS and PHP? [closed]

筅森魡賤 提交于 2019-12-18 10:22:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm looking for a simple Template engine that works both on client side with JS ánd on server side with PHP. That means I want to be able to use the same template definition for both use cases. Do you know any templating engines that have official implementations in both JS and PHP? 回答1: If you like JS->PHP

Migrating to Typeahead 0.10+ with Hogan

你离开我真会死。 提交于 2019-12-18 06:48:37
问题 I have been using Typeahead 0.9.3 with Hogan 2 for a while and it was very straight forward to setup. in 0.9.3 I did something like: $('input.search-query').typeahead([ { name: "pages" ,local: localSuggestions ,template: '<div class="tt-suggest-page">{{value}}</div>' ,engine: Hogan } ]); According to the Migration Guide to 0.10 "Precompiled Templates are Now Required", so in 0.10.3 I'm trying: $('input.search-query').typeahead(null, { name: "pages" ,source: taSourceLocal.ttAdapter()

When to use PHP template engines

心已入冬 提交于 2019-12-18 03:03:43
问题 I am building a website in php with lot of pages and we are a team of 9 working on it. So just want to explore that when should we use PHP template engines and when we shouldn't. So I'm interested in pros and cons of using PHP Template engines so I can make a decision whether to use it in my case or not. 回答1: PHP is a template language. In my experience so far with various template systems, the conclusion was pretty simple: use none . Instead, write PHP as it should be written! Never do

node.js and Handlebars: HTML compiled is escaped

浪尽此生 提交于 2019-12-18 02:50:33
问题 Im using handlebars in a node aplication, and I have trouble. This is the template index.html {{CONTENT}} This is the code var fs = require("fs"); var handlebars = require("handlebars"); var data = { CONTENT: "<b>Hello world!</b>" }; var templateFile = fs.readFileSync('./index.html', 'utf8'); var template = handlebars.compile( templateFile ); var html = template(data); The problem is that the tags <B> are escaped to <B> How can I avoid this? 回答1: From handlebarsjs.com : Handlebars HTML

node.js and Handlebars: HTML compiled is escaped

泪湿孤枕 提交于 2019-12-18 02:50:01
问题 Im using handlebars in a node aplication, and I have trouble. This is the template index.html {{CONTENT}} This is the code var fs = require("fs"); var handlebars = require("handlebars"); var data = { CONTENT: "<b>Hello world!</b>" }; var templateFile = fs.readFileSync('./index.html', 'utf8'); var template = handlebars.compile( templateFile ); var html = template(data); The problem is that the tags <B> are escaped to <B> How can I avoid this? 回答1: From handlebarsjs.com : Handlebars HTML

How do I execute ruby template files (ERB) without a web server from command line?

萝らか妹 提交于 2019-12-17 17:52:06
问题 I need ERB (Ruby's templating system) for templating of non-HTML files. (Instead, I want to use it for source files such as .java, .cs, ...) How do I "execute" Ruby templates from command line? 回答1: You should have everything you need in your ruby/bin directory. On my (WinXP, Ruby 1.8.6) system, I have ruby/bin/erb.bat erb.bat [switches] [inputfile] -x print ruby script -n print ruby script with line number -v enable verbose mode -d set $DEBUG to true -r [library] load a library -K [kcode]