template-engine

How do I reference a field name that contains a dot in mustache template?

半世苍凉 提交于 2019-12-01 05:28:42
How do I reference a field name that contains a dot in mustache template? For instance, if I have a view like { "foo.bar": "my value" } then how can I put my value into a template? Using {{foo.bar}} doesn't work because mustache thinks the dot is part of the path, like there should be a "foo" that has a "bar". Will Klein You can't read a key with a . in it from Mustache. The Mustache spec dictates that . is used to split content names. Mustache provides a means of escaping but only for HTML content. Mustache spec: interpolation You will need to pre-process your data to make it usable in a

In Ansible, how can I combine a default dictionary in a role with a dictionary passed to that role as an argument?

泄露秘密 提交于 2019-12-01 03:23:23
问题 In Ansible, how can I combine a default dictionary in a role with a dictionary passed to that role as an argument? 回答1: As a solution by example, consider role nginx-reverse-proxy : nginx-reverse-proxy/defaults/main.yml : default_nginx: application_context: /{{ application_name }}-{{ application_component_name }} reverse_proxy: port: 8080 nginx-reverse-proxy/templates/reverse-proxy.conf : {% set combined_nginx = default_nginx | combine(nginx, recursive=true) -%} location {{ combined_nginx

Is the NVelocity project dead? Are there alternatives?

偶尔善良 提交于 2019-12-01 02:07:11
I'm looking for a template engine for .NET/C# to generate email notifications in my application. I read about NVelocity in the past and think it would fit my needs, but it seems this project is dead. Would you still recommended to use NVelocity for that purpose or can you suggest any alternatives? Note: I found some other templating engines, but these are mostly "view-engines" for ASP.NET MVC (Brail, NHaml, etc.). But I think these are not what I'm looking for. Pervez Choudhury The Castle Project forked the project and have been maintaining it, and most recently released version 1.1.1 on 10

Can PHP communicate with XSLT?

天涯浪子 提交于 2019-12-01 01:43:25
I want to use a combination of xml & xslt as a templating system. The question that I want answered is: can xslt and PHP communicate with each other (i.e share variables)? The basic task you can do with PHP is to define which XML file to transform with which XSLT script. Using this you can a) pass parameters from PHP to XSLT and b) use PHP functions in the XSLT script. This example shows how - first PHP file: <?php function f($value){ //do something return $value; } $proc=new XsltProcessor; $proc->registerPHPFunctions(); $proc->setParameter('', 'p', '123'); $proc->importStylesheet(DOMDocument:

Looking for a (pseudo) XSLT preprocessor/templater to make it less verbose [closed]

只谈情不闲聊 提交于 2019-11-30 22:57:18
Does anybody know of a preprocessor for XSLT to make it less verbose? Something like what SASS is to CSS, a little proggy that will take light syntax: "/": { <html> <head> <title>My book collection</title> </head> <body> {@ "//media"} {@ quantity = calc_abs_value("//total_quantity")} Price : {@ multiply(price:"//item[@selected='true'][@price]",qty :$quantity) } </body> </html> } "media[@type='book']": { <div id="{@id}"> {title} by {author} published in {published_date} </div> } function calc_abs_value(value) { if ($value < 0) {- $value} else {$value} } function multiply(price,qty:"1") { switch

Is the NVelocity project dead? Are there alternatives?

老子叫甜甜 提交于 2019-11-30 21:33:23
问题 I'm looking for a template engine for .NET/C# to generate email notifications in my application. I read about NVelocity in the past and think it would fit my needs, but it seems this project is dead. Would you still recommended to use NVelocity for that purpose or can you suggest any alternatives? Note: I found some other templating engines, but these are mostly "view-engines" for ASP.NET MVC (Brail, NHaml, etc.). But I think these are not what I'm looking for. 回答1: The Castle Project forked

Can PHP communicate with XSLT?

守給你的承諾、 提交于 2019-11-30 21:17:54
问题 I want to use a combination of xml & xslt as a templating system. The question that I want answered is: can xslt and PHP communicate with each other (i.e share variables)? 回答1: The basic task you can do with PHP is to define which XML file to transform with which XSLT script. Using this you can a) pass parameters from PHP to XSLT and b) use PHP functions in the XSLT script. This example shows how - first PHP file: <?php function f($value){ //do something return $value; } $proc=new

T4 Templates - suitable for generating C++ code?

爱⌒轻易说出口 提交于 2019-11-30 20:47:09
Are there any issues which might make MS's T4 Template code-generation system unsuitable for generating C++ code? It can generate any text you want, including C++ code. 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 there are some pretty convincing benefits of T4: The generated code from T4 is easy to debug and understand

Smarty benchmark, anyone?

自闭症网瘾萝莉.ら 提交于 2019-11-30 20:09:14
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 Because in the end, Smarty compiles and caches the templates files to native PHP-code, there is indeed no theoretical performance difference. Of course there will always be some performance loss due to the chunk of

laravel blade, how to append to a section

点点圈 提交于 2019-11-30 16:57:20
If you look to laravel official documentation http://laravel.com/docs/4.2/templates It says that giving this layout: <!-- Stored in app/views/layouts/master.blade.php --> <html> <body> @section('sidebar') This is the master sidebar. @show <div class="container"> @yield('content') </div> </body> </html> Extended by this view @extends('layouts.master') @section('sidebar') <p>This is appended to the master sidebar.</p> @stop @section('content') <p>This is my body content.</p> @stop Will append to the section sidebar . But actually if you try is it doesn't append, it just override the content from