dust.js

How to display message using connect-flash and express-messages on .dust file on Node

你。 提交于 2021-02-08 10:09:28
问题 I'm using Nodejs and Expressjs and Kraken , I need to display message when added a product on index but I tried many time for to config but messages still not appear as I expect. Here is my config.js: var flash = require('connect-flash'); app = module.exports = express(); app.use(kraken(options)); //flash app.use(flash()); app.use(function (req, res, next) { res.locals.messages = require('express-messages')(req, res); next(); }); My controller : router.post('/somePath', function (req, res) {

How do you include a raw, uncompiled partial in dust.js?

南楼画角 提交于 2020-01-07 03:07:07
问题 I have dust working reasonably well, but I'd like to be able to include a file, such as a css file, without compiling and rendering it. It seems like maybe I need to create an onLoad handler that loads the file and registers the content directly. Is there a way to do this within dust already? 回答1: You can take advantage of Dust's native support for streams and promises to make file inclusion really nice. The exact implementation depends on whether you're running Dust on the server or the

How to write dustjs in php code without nodejs

孤街浪徒 提交于 2020-01-05 08:35:16
问题 Current I did the dustjs in client javascript as below <!DOCTYPE html> <html> <head> <script src="lib/dust-full-0.3.0.min.js" type="text/javascript"></script> <script src="vendor/jquery-1.7.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ // JSON response from server var json_object = { "profile_skill": "Profile Skill", "skills": [ { "name": "JavaScript" }, { "name": "Ruby" }, { "name": "Java" } ] } // render method dustRender = function

Dust if condition

烈酒焚心 提交于 2020-01-01 08:46:29
问题 I'm having trouble with a dust if condition. I have a partial that points to 2 different dust templates depending on the Country code {>"receipt/merchantInfo/merchantInfo_{countryCode}"/} I'm trying to make an if else condition that will figure out if the {countryCode} is US. Example: {@if cond="'{countryCode}' == 'US'"} <p>is country code US</p> {:else} <p>is NOT country code US</p> {/if} This isn't working. Anyone have an idea where I went wrong with this? 回答1: The @if helper has been

$idx and $len in a dust.js conditional statement

陌路散爱 提交于 2020-01-01 04:33:23
问题 The documentation on dust is just awful , I've already perused everything I can possibly find and cannot figure out how this is supposed to work. I'm having this problem with the supposed special values $idx and $len, which, if I have guessed correctly, return the current index while iterating over an array-like section and the length of said array-like section. I have an @if condition (multiple actually) that I'm trying to workout to format a template, and the values are just not working as

Does Dust.js provide a way to reference an object key/value by keywords “key” and “value”?

前提是你 提交于 2019-12-25 02:57:25
问题 I want to use Dust.js as a client template engine. I have a data json like this: var data = { "Foo": [{ "somekey": "somevalue", "otherkey": "othervalue" }, { "somekey": "somevalue", "otherkey": "othervalue" }], "Bar": [{ "somekey": "somevalue", "otherkey": "othervalue" }, { "somekey": "somevalue", "otherkey": "othervalue" }] } I do not know in advance what uppermost object keys will be - I do not know Foo and Bar keys, they can be any value. So, I need to iterate through this json by keywords

How to render dust template with backbone

坚强是说给别人听的谎言 提交于 2019-12-24 14:45:25
问题 I'm trying to display a dust template (compiled) within a backbone view. here is my render function in the view : render: -> dust.render("customer-item", @model.toJSON(), (err, output) -> throw err if err $(@el).html output ) @ When i lead the view i see 2 divs added inside my container (corresponding to the 2 models that should be loaded) but they are both empty. The individual template is not redered... When I debug the "output" variable i see the template so in theory it should be loaded

Using dustjs how do I show a block of code when an array's size is greater than one

♀尐吖头ヾ 提交于 2019-12-24 06:44:47
问题 I am using dust 1.1.1. I've tried nesting the @size help inside of an @if but that broke. Another trick to it is once I've determined the length is greater than one I then want to iterate through the array. 回答1: The Dust grammar does not allow a helper to be used inside another helper, except in the body. Instead, I would try something like this: {#myArray} {@gt key=$len value=1}{.}{/gt} {/myArray} This will only output the value of the element in the array if the length of the array ( $len )

Using dustjs how do I show a block of code when an array's size is greater than one

随声附和 提交于 2019-12-24 06:44:13
问题 I am using dust 1.1.1. I've tried nesting the @size help inside of an @if but that broke. Another trick to it is once I've determined the length is greater than one I then want to iterate through the array. 回答1: The Dust grammar does not allow a helper to be used inside another helper, except in the body. Instead, I would try something like this: {#myArray} {@gt key=$len value=1}{.}{/gt} {/myArray} This will only output the value of the element in the array if the length of the array ( $len )

Is it possible / sensible to use external templating engine like dust.js or any other with anjularjs?

*爱你&永不变心* 提交于 2019-12-24 04:35:28
问题 I had this urge to use dust.js templates as it provides a much better performance for UI rendering by caching the templates. But in my current project we are using angularjs. It is even possible/sensible to use dust.js or any other templating engine with angular js ?? Even if i use dust.js will I lose the 2-way binding .. ? Please suggest considering a relatively large SPA.. ? P.S. I am a novice in both angular and dust. 回答1: Sounds like a good use case for a filter! Be aware that dust.js is