template-engine

RazorGenerator, Templates, and @Html

天大地大妈咪最大 提交于 2019-11-28 03:51:50
问题 I'm trying to use RazorGenerator as an email template engine. I want to take a model with the data, assemble the correct set of partial views, and return HTML that I can email out. Edit: In addition to this workflow, any solution would need to be editable as a .cshtml file and be able to be compiled into a dll . For various reasons, it is not practical to deploy the cshtml files themselves - if we can't embed all our razor views into a single file, then we can't use that suggestion. Hence

Truncate string in Laravel blade templates

痴心易碎 提交于 2019-11-28 03:38:34
Is there a truncate modifier for the blade templates in Laravel, pretty much like Smarty? I know I could just write out the actual php in the template but i'm looking for something a little nicer to write (let's not get into the whole PHP is a templating engine debate). So for example i'm looking for something like: {{ $myVariable|truncate:"10":"..." }} I know I could use something like Twig via composer but I'm hoping for built in functionality in Laravel itself. If not is it possible to create your own reusable modifiers like Smarty provides. I like the fact that Blade doesn’t overkill with

What is the fastest template system for Python?

流过昼夜 提交于 2019-11-28 02:50:03
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 ? 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 cElementTree 107.85 ms StringIO 41.48 ms Jinja 2 36.38 ms Cheetah template 34.66 ms Mako Template 29.06 ms Spitfire

Using VueJS with a Go backend

泪湿孤枕 提交于 2019-11-28 01:03:55
问题 I want to use Go templates as well as VueJS for data-binding. Has anyone integrated both before? I wish to use VueJS primarily for Ajax calls as doing it manually(or with jQuery) always leaves my code messy. To be more specific, if I have a simple <p> tag whose value is generated from a Go template like so: {{.Color}} Now I want to bind to the value in like so: {{someVariable}} Both are for the same tag. 回答1: If you are mixing Vue.js with another templating system you can choose to change the

Thymeleaf/Spring MVC - How do you nest variables/expressions in a Link expression?

情到浓时终转凉″ 提交于 2019-11-27 23:53:21
问题 For example, my controller method in Spring does this: model.addAttribute("view_name", "foobar") And I'm trying to do this in my Thymeleaf template: <link th:href="@{/resources/libs/css/${view_name}.css}" rel="stylesheet" /> But the rendered result is this: <link href="/app/resources/libs/css/${view_name}.css" rel="stylesheet" /> So it's not replacing the ${view_name} like I'm expecting. What am I doing wrong? In general, how do you nest expressions like that in Thymeleaf? 回答1: Since you are

Good Javascript template engine to work with JSON

て烟熏妆下的殇ゞ 提交于 2019-11-27 23:20:56
I have looked at jTemplates and it's worth a try. Are there any other template engines other than jTemplates? 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.). Did you try pure.js ? The main difference with the dozens of JS templating engines available is that PURE leaves the HTML totally separated from the JS logic. And it's pretty fast too. However it is not the common <% ... %>

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

放肆的年华 提交于 2019-11-27 19:02:27
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? You can switch delimiters to something that won't conflict with the triple mustaches, like erb-style tags: {{=<% %>=}} {{{ { "name": "<% name %>", "description": "<% description %>" } }}} {{{debug

Velocity vs. FreeMarker [closed]

谁说胖子不能爱 提交于 2019-11-27 17:40:14
Velocity or FreeMarker? They look pretty much the same, even the syntax? What to use? Or when to use what? skaffman Velocity isn't really under active development any more. Freemarker is. Freemarker is also a lot more flexible, in my experience. The goals for the projects are different. Velocity's goal is to keep templates as simple as possible, to help maintain a segregation between logic and presentation, so you don't slide down the slippery slope of sticking code in templates. Sometimes this is the right thing. Of course, sometimes being able to wire complicated logic directly into

C# template engine [closed]

落花浮王杯 提交于 2019-11-27 17:22:50
I am looking for a stand-alone, easy to use from C# code, template engine. I want to create an HTML and XML files with placeholders for data, and fill them with data from my code. The engine needs to support loops (duplicating parts of the template form more that one object) and conditions (add parts of the template to the final HTML/XML only if some conditions are true). Can someone recommend a good option for me, and add a link to more-or-less such code sample, and some documentation about how to use the recommended component for my needs? I also need to use loops to duplicate table rows, or

React.js: Wrapping one component into another

眉间皱痕 提交于 2019-11-27 16:40:42
Many template languages have "slots" or "yield" statements, that allow to do some sort of inversion of control to wrap one template inside of another. Angular has "transclude" option . Rails has yield statement . If React.js had yield statement, it would look like this: var Wrapper = React.createClass({ render: function() { return ( <div className="wrapper"> before <yield/> after </div> ); } }); var Main = React.createClass({ render: function() { return ( <Wrapper><h1>content</h1></Wrapper> ); } }); Desired output: <div class="wrapper"> before <h1>content</h1> after </div> Alas, React.js doesn