template-engine

How can one pass a non-string parameter between page and master templates?

十年热恋 提交于 2019-12-22 18:21:22
问题 This shouldn't work: page: #{extends 'master.html'/} #{set parameter:foo.bar/} //foo is passed from contoller master.html: #{list items:parameter, as item} ... #{/list} Is there any way to do this trick? 回答1: I had to play with this a bit, but the #{set} tag does not work well for lists. Try this in your page (not master.html): %{ parameter = foo.bar; }% Hope that helps. 来源: https://stackoverflow.com/questions/8055058/how-can-one-pass-a-non-string-parameter-between-page-and-master-templates

ASP.MVC: Implementing a non-templated view engine?

拥有回忆 提交于 2019-12-22 10:59:42
问题 I'm fairly new to ASP.MVC. For our new Web application I'm considering between two options for view engines: Using some of the available view engines (the default one, NVelocity, Brail, etc.) as a primary view code generator. Implementing an application-specific C# DSL for generating HTML code so that the main bulk of the view code is stored in C# classes (using some sort of smart HTML generation like the one described by Jimmy Bogard). The idea behind 2. would be to reduce the need for

Call play2 template with variable arguments of type Html

空扰寡人 提交于 2019-12-22 10:33:53
问题 How can I call a template with a variable number of arguments that have Html type in play? I created a template in play2 defined like the following: @(tabs: Html*) <div class="btn-group" style="margin-bottom:20px"> @for((tab,index) <- tabs.zipWithIndex){ <a class="btn btn-mini btn-info active" id="display-hierarchy-@index" href="javascript:void(0)"><i class="icon icon-random icon-white"></i></a> } </div> @for((tab,index) <- tabs.zipWithIndex){ <div id="display-hierarchy-tab-@index" class=

template engine implementation

只愿长相守 提交于 2019-12-22 10:33:27
问题 I am currently building this small template engine. It takes a string containing the template in parameter, and a dictionary of "tags,values" to fill in the template. In the engine, I have no idea of the tags that will be in the template and the ones that won't. I am currently iterating (foreach) on the dictionnary, parsing my string that I have put in a string builder, and replacing the tags in the template by their corresponding value. Is there a more efficient/convenient way of doing this?

Is it possible to use Razor as a standalone library (without any asp.net business) on OSX (via Mono)

非 Y 不嫁゛ 提交于 2019-12-22 08:31:48
问题 I would like to write a proof of concept MonoMac app which renders html "Views" using c# and Razor. Is this possible? If not, does anyone recommend any other Templating engines that compare to the simplicity of Razor. I don't mind writing it in Objective-C if I have to, but Mono would be simpler. 回答1: I think you may be interested in this project. You just have to download zip which consists of two DLLs, reference them in your project and examples like these just works. Have in mind that you

How to use .html file extensions for handlebars in express?

自古美人都是妖i 提交于 2019-12-22 05:28:30
问题 So I was wondering how I could use .html extensions instead of .handlebars or .hbs extensions. I am doing this so I can develop using regular html so that my frontend developers can seamless edit files in their IDEs without any extra configuration. Plus it will help installing html templates much faster into our express applications. 回答1: So I was able to do this by changing three things in my app.js file I hope this helps everyone out as much as it helped me! var express = require('express')

Efficient plain text template engine

空扰寡人 提交于 2019-12-21 21:38:33
问题 I have a simple alert system that grabs number on the web, mix them with pre-defined text template to get an alert, and send it to clients. The alert is quite simple plain text, so I would not expect much other than plain text, numbers, simple functions(such as ifthenelse), the quicker the better. So are there any existing open source solutions for this? Thanks! 回答1: I would use Razor Engine for this. A templating engine built upon Microsoft's Razor parsing technology. The RazorEngine allows

How to use Brail as a stand-alone general purpose templating engine (like NVelocity)?

最后都变了- 提交于 2019-12-21 19:45:16
问题 I've been using NVelocity as a stand-alone templating engine in my text file generator. The problem with NVelocity is that the macros are quite shaky; pretty much all errors I get are from faulty macro implementation. It would be cool if I could just use some other templating engine, such as Brail. That way I would just write functions that output strings. What's the best way of embedding Brail engine? I would like to just pass it a string containing the template (not reading from disk), and

How to use the John Resig JavaScript Micro-Templating engine?

邮差的信 提交于 2019-12-21 09:14:01
问题 I have searched for a bit on a basic example on using the John Resig JavaScript Micro-Templating engine on Google but came out dry. I decided to bring it to base guys. Can anyone help with a simple example on using this engine? I have never used a client side template engine before. Update: This is the complete HTML document. Thanks to Will. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>John Resig JavaScript Micro-Templating engine</title> <script src="jquery-1.3.2.js" type="text

How to implement pluralize & other extensions using Playframework 2.0

旧时模样 提交于 2019-12-21 04:53:30
问题 In playframework 1.x there used to be some bundled java extensions for the templating engine: http://www.playframework.org/documentation/1.2.3/javaextensions I'm looking for the same functionality in playframework 2.0. For example how would I do this? colour${['red', 'green', 'blue'].pluralize()} I am doing this malually now: We have @colours.size colour@if(colours.size > 0){s} the must be a cleaner more reusable way to do this? 回答1: You can leverage the pimp my lib Scala pattern to implement