templating

How to evaluate javascript functions in underscore with mustache notation?

爱⌒轻易说出口 提交于 2019-12-22 17:59:10
问题 I want to do something like this: <script id="tmpl-books" type="text/template"> <ul> <% for (var i = 0; i < books.length; i++) { %> <% var book = books[i]; %> <li> <em><%= book.title %></em> by <%= book.author %> </li> <% } %> </ul> </script> in my code, but I am using JSP so I have to use the {{ }} notation, but when I do this {{ for(var... }} does not work. <script id="tmpl-books" type="text/template"> <ul> {{ for (var i = 0; i < books.length; i++) { }} <% var book = books[i]; %> <li> <em>{

Is there a html-only templates system for php?

元气小坏坏 提交于 2019-12-22 05:18:21
问题 I have started coding in clojure, and I'm really impressed by Enlive. One thing that I really like about it is that Enlive uses html-only templates. So a template is a file with html in it, ending in .html, simple as that. It gets parsed into a dom tree and then that dom tree is manipulated by clojure/enlive, combined, made dynamic, etc. No syntax in the html template files, a beautifully clean separation. Another example of a similar system, done via javascript, is PURE. Is there anything

Jade - Controlling line-breaks in the HTML output

梦想与她 提交于 2019-12-22 04:36:35
问题 I have a simple search form I wish to implement using Jade. form input( type="text" size="16" placeholder="Enter your keywords") input( type="button" value="Search") The output is rendered as: <form> <input type="text" size="16" placeholder="Enter your keywords"> <input type="button" value="Search"> </form> This is perfect except that the line-break is causing a space between my button and the search button. I need no space between the textbox and the button. I need the code to render like

Convert Jade to EJS

大兔子大兔子 提交于 2019-12-21 21:15:06
问题 Can anyone please help by convert this Jade to EJS? extends layout block content h1. User List ul each user, i in userlist li a(href="mailto:#{user.email}")= user.username 回答1: There is no block but an include logic available in EJS. Split up the "main layout" that way that you can include a header and footer (or whatever suits your needs). The iteration is expressed in plain JavaScript escaped in sequences of <% ... %> . Using <%= ... %> directly outputs the referenced var. Your resulting

Meaning of Dollar Sign & Curly Braces Containing Javascript Block Outside of HTML Script Tag

有些话、适合烂在心里 提交于 2019-12-21 04:57:32
问题 I'm currently reading 'Javascript Web Applications' (O'Reilly, Alex MacCaw) and very early on there's a code snippet which might appear to execute a JS function, within an HTML document, yet it is not enclosed by <script> tags: // template.html <div> <script> function doSomething(aParam) { /* do stuff ... */ }; </script> ${ doSomething(this.someX) } </div> Please could someone kindly explain the dollar-sign-curly-brace notation ? I'm currently learning JS and I haven't seen this before, so I

Razor code between double quotes

前提是你 提交于 2019-12-19 17:15:32
问题 In a Razor View Engine template, I want to do the following: I want to put some code between the double quotes of an html attribute . The trouble is that the piece of code I want to insert contains some double quotes itself. <a href="Url.Action("Item", new { id = Model.Item.Id, page = page });">@page</a> You can easily see how things turn horribly wrong :-) I know i can calculate the link in a variable and then use it, but I'd rather not: @{ var action = Url.Action("Question", new { id =

Razor code between double quotes

青春壹個敷衍的年華 提交于 2019-12-19 17:15:12
问题 In a Razor View Engine template, I want to do the following: I want to put some code between the double quotes of an html attribute . The trouble is that the piece of code I want to insert contains some double quotes itself. <a href="Url.Action("Item", new { id = Model.Item.Id, page = page });">@page</a> You can easily see how things turn horribly wrong :-) I know i can calculate the link in a variable and then use it, but I'd rather not: @{ var action = Url.Action("Question", new { id =

How can I position ViewModels in an ItemsControl

纵然是瞬间 提交于 2019-12-19 11:16:12
问题 My mainwindow ViewModel has an ObservableCollection of ViewModels, called ViewModels. The Mainwindow XAML has an ItemsControl with ItemsSource bound to ViewModels. When I have <ItemsControl ItemsSource="{Binding ViewModels}" /> The Views associated with each ViewModel in the collection are rendered one below the other. The Views are UserControls, displaying dataGrids. How can I position them in a customizable way, for example such that VM1 is on the left, and VM2 and VM3 are stacked one on

Twig: Include external Code from an SVG file

痴心易碎 提交于 2019-12-18 19:41:37
问题 Is it possible to inlcude code from a svg file directly into a twig template file? Something like: {% include 'my.svg' %} that will result in: <svg viewbox=".... /> 回答1: One way of doing this: {{ source('my.svg') }} Read more here: https://www.theodo.fr/blog/2017/01/integrating-and-interacting-with-svg-image-files-using-twig/ 回答2: Had a similar issue, ended up renaming my svgs to be .twig files. {% include 'my.svg.twig' %} 回答3: You can do in a Drupal8 theme via setting a new variable:

Twig: Include external Code from an SVG file

旧时模样 提交于 2019-12-18 19:40:11
问题 Is it possible to inlcude code from a svg file directly into a twig template file? Something like: {% include 'my.svg' %} that will result in: <svg viewbox=".... /> 回答1: One way of doing this: {{ source('my.svg') }} Read more here: https://www.theodo.fr/blog/2017/01/integrating-and-interacting-with-svg-image-files-using-twig/ 回答2: Had a similar issue, ended up renaming my svgs to be .twig files. {% include 'my.svg.twig' %} 回答3: You can do in a Drupal8 theme via setting a new variable: