templating

Loop by integer value with Nunjucks Templating

拜拜、爱过 提交于 2019-12-09 14:11:07
问题 I'm quite new to nunjucks and from what I have read this is not possible, but I was wondering if anyone had come up with a way of doing this. I am basically looking to perform a for loop in a nunjucks template based on a value rather than an object's size. Say you pass the following data to a template. Assume the number of rooms value is the value of a selected option from a <select> element : data : { numberOfRooms : 4 } In traditional JS I could write a for loop and limit the loop based on

Passing an array of objects to a partial - handlebars.js

帅比萌擦擦* 提交于 2019-12-09 11:54:31
问题 Im trying to pass an array of objects into a partial as an argument: {{> partial [{title: "hello", year: "2015"}, {title: "hello2" year: "2015"}] }} and then on the partial: <div> {{#each this}} <label>{{title}}</label> <label>{{year}}</label> {{/each}} </div> ... but nothing shows up. Is there a way to pass array data to a partial? Thanks in advance. 回答1: Create a helper that parses the JSON and wrap your partial with this context. Template: {{#getJsonContext '[{"title": "hello", "year":

Laravel Blade Templates Section Repeated / cache error

亡梦爱人 提交于 2019-12-08 19:42:15
问题 I am looking to Bootstrap my site and as such, have put common twitter bootstrap components into blade templates. sidebar.blade.php @include('panel1') @include('panel2') panelTemplate.blade.php <div class="panel panel-primary"> <div class="panel-heading"> <div class="panel-title"> @yield('title') </div> </div> <div class="panel-body"> @yield('body') </div> <div class="panel-footer"> @yield('footer') </div> </div> This way, every time I wish to use a panel, then I can use @extends(

Hide grafana panels based on selected template variable

为君一笑 提交于 2019-12-08 17:30:33
问题 I am trying to develop kind of dropdown list with metrics and accordingly to selected metric specific panel supposed to appear on dashboard. And vice versa if metric unselected, panel should be hidden. I found the link http://search-devops.com/m/k2DBF2DCJuDrRWa1&subj=Re+grafana+Hide+panels+based+on+results where 2015-10-26 it was told that it is not possible to do. But maybe some functionality was developed until that time which allow to show/hide grafana panel? Thank you 回答1: Need to use

Using Nested Include Twig

泪湿孤枕 提交于 2019-12-08 13:11:16
问题 in my header.twig : <ul class="nav list-unstyled"> {% for item in data %} {% include 'partials/item/header/item-nav.twig' %} {% endfor %} </ul> in my item-nav.twig <li><a href="{{ data.url }}">{{ data.menu_name }}</a></li> header.twig is included in base.twig. I rendered base.twig in base.php file. Where I can add data array to process data.url and data.name ? in base.php ? or i rendered file php again ? Thank you. base.php include __DIR__ . '/../vendor/autoload.php'; $renderer = new

What should I worry about Python template engines and web frameworks? [closed]

倖福魔咒の 提交于 2019-12-08 11:52:17
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am a C# and ASP.NET MVC developer. I've completed some Python console applications but I am new to use Python for web applications.

jsmart - Can't get template contents (in time?)

流过昼夜 提交于 2019-12-08 07:31:07
问题 I'm trying to use jsmart to render Smarty3 templates on the client-side. If you've no experience with them, keep reading because it could just be a simple JavaScript error that I'm making. It works for simple templates: I create the template (which I receive via AJAX), then render it (passing it the data), as per the documentation: var template = new jSmart(templateReceivedViaAJAX); var content = template.fetch({"firstname":"adam", "secondname":"lynch"}); Then I simply stick the rendered

Loading underscore.js templates from a separate file

随声附和 提交于 2019-12-07 19:31:31
问题 I'm currently using underscore.js for templating in a project, templates are stored in script tags with a type of text/template and loaded by id. I'm wondering if it's possible to continue to use the same system, but move the templates to a separate file? The only way I can think about doing this is declaring the templates as global vars in a separate file, but that seems ugly. Note: I don't want to use Jammit or some other build system for mashing everything together into a single file at

Smarty - 'unable to write file… templates_c'. (smarty_internal_write_file.php:44) [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-07 09:44:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm using Smarty for the first time. It works fine on my laptop (MAMP) but when I try and run a basic template on my production server (Windows) I get this error message: Fatal error: Uncaught exception 'SmartyException' with message 'unable to write file C:\Inetpub\vhosts\path\to\web\root\smarty\templates_c

Creating active navigation state with Meteor and Iron Router

别来无恙 提交于 2019-12-07 07:41:26
问题 I want to add a class of 'active' to the nav list item that is currently being rendered by Iron Router. Here's my markup: <ul> <li> {{#linkTo route="option1"}} <span class="fa fa-fw fa-option"></span> Option 1 {{/linkTo}} </li><li> {{#linkTo route="option2"}} <span class="fa fa-fw fa-option"></span> Option 2 {{/linkTo}} </li> </ul> I've read through the guide and various articles but can't find this covered anywhere. Assuming I'll need some sort of helper? 回答1: I think you might find meteor