template-engine

Can I run a ASPX and grep the result without making HTTP request?

为君一笑 提交于 2019-11-30 15:54:36
How can I just make a function call, without URL, and without HTTP, to a simple ASP.NET file, and capture the byte stream it generated? More background information, I need a some kind of template can put a little logic inside, to render some INI like text files. I give up those libraries ported from Java and come up a solution of using ASP.NET for template engine. (I am NOT using it to build a website, not even a HTML.) I have written a ASP.NET page (no WebForm, no MVC), which accept a XML POST, and it generate a long text file based on a set of simple but not too simple rules. I generate the

how to use Smarty better with PHP?

大兔子大兔子 提交于 2019-11-30 13:58:29
I found that using Smarty with PHP, sometimes extra time will need to be used for 1) using quite different syntax than PHP itself 2) need to check small cases, because documentation doesn't give finer details, such as for "escape" http://www.smarty.net/manual/en/language.modifier.escape.php it doesn't say escape:"quotes" is for double quotes only or for single quotes as well, so you need to write code to test it. Also for the case of escape:"javascript" -- can't tell exactly what and how it is escaped. 3) for something complicated, need to write helper functions or modifiers, so it needs a

Executing javascript inside Handlebars template

假装没事ソ 提交于 2019-11-30 13:09:32
I'm totally new to js template engines. Handlebars seems to be the popular choice. I don't dislike the syntax for doing conditions, loops and so on, but since I'm perfectly capable of and feel more comfortable using plain old js and I'm not planning to let anyone who doesn't know js touch my templates, I'm asking if Handlebars supports this. Of course the most popular choice isn't always the best. I'm more of a Mootools guy and jQuery drives me crazy(great library, just not for me). So if Handlebars was jQuery of template engines, what would be Mootools? Peter Lyons One of the central ideas

Import javascript files with jinja from static folder [duplicate]

吃可爱长大的小学妹 提交于 2019-11-30 13:09:32
This question already has an answer here: Link to Flask static files with url_for 2 answers Pass parameter with Python Flask in external Javascript 2 answers 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 is, how can i change the way how jinja looks for files? Instead of search in templates folder, in this case, search in the

Cross Java and Javascript Template Language?

痴心易碎 提交于 2019-11-30 09:31:07
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. Google Closure/Soy templates . The Wikipedia Page for Web Templating Languages reveals another one: Casper . Both these solutions don't use a common template file which is directly evaluated in JS or Java. The

T4 template and run-time parameters

流过昼夜 提交于 2019-11-30 07:18:09
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 Template. As soon as I create a parameter in the .tt file, the Host freak out saying that it doesn't know how

Client-side templating language with java compiler as well (DRY templating)

送分小仙女□ 提交于 2019-11-30 06:47:06
问题 I want to be able to define templates once and use them to render html from both the server-side as well as the client-side. (DRY principle and all that) The API that I'm envisioning is simply this: render(JSON, template) --> html. I'm using a java-framework (actually Play framwork, but I don't think this is framework specific). I've read a lot of similar questions, the latest, and most helpful being: Templating language for both client-side and server-side rendering. I pretty much agree with

twig - pass function into template

一曲冷凌霜 提交于 2019-11-30 06:39:10
Currently I place my function in a class and pass an instance of this class into template and call my required function as a class method. {{ unneededclass.blah() }} I need to do like below {{ blah() }} Is it possible? Austin Hyde Update 5/14/2015 Commenters point out that I'm mostly wrong. If you really need a function, and not a filter or macro, you can do it as suggested in the Twig docs : $twig = new Twig_Environment($loader); $function = new Twig_SimpleFunction('blah', function () { // ... }); $twig->addFunction($function); And use like {{ blah() }} In short, no, this is not possible.

What is the best way to insert HTML via PHP?

谁说我不能喝 提交于 2019-11-30 06:13:19
问题 Talking from a 'best practice' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the latter), but I'm curious to know which you think is best. <?php if($a){ ?> [SOME MARKUP] <?php } else{ ?> [SOME OTHER MARKUP] <?php } ?> Opposed to: <?php unset($out); if($a) $out = '[SOME MARKUP]'; else $out = '[OTHER MARKUP]'; print $out; ?> 回答1: If you are going to do things that way, you want to separate your logic and

T4 Templates - suitable for generating C++ code?

萝らか妹 提交于 2019-11-30 04:02:11
问题 Are there any issues which might make MS's T4 Template code-generation system unsuitable for generating C++ code? 回答1: It can generate any text you want, including C++ code. 回答2: A bit lengthy answer yet I think some might find it interesting I would say T4 is excellent to generate C++ with Some might retort that C++ already has tools to do MetaProgramming with like: The Preprocessor Using the preprocessor and higher-order macros you can achieve somewhat what you can do with T4, but I say