Questions tagged [dust-helpers]

Context helpers are augments to the core Dust template syntax.

https://github.com/linkedin/dustjs-helpers

Context helpers are augments to the core Dust template syntax. It's possible to write your own helpers and extend the functionality of Dust's templating system.

The helpers we provide as part of this repository fulfill some of the most common use cases encountered while using Dust. We provide official support for these helpers as part of the core Dust library.

19 questions
5
votes
1 answer

Function call and checking results in DustJs

I am combining connect-roles with dust template ejs template have something like this syntax <% if (userCan('impersonate')) { %> <% } %> and that in jade if userCan('impersonate') …
Anatoly Ruchka
  • 543
  • 4
  • 17
3
votes
1 answer

How to run or condition in Dust template

I am using "dustjs-helpers": "1.6.0", with "dustjs-linkedin": "^2.6.0" . In my template I need to check an OR condition like if( cherry === true || berry === true) path/to/template1/ else path/to/template2/ How do I accomplish this with the…
Rohit Choudhary
  • 2,253
  • 1
  • 23
  • 34
2
votes
2 answers

dustjs OR condition over multiple parameters

I have an object with multiple properties viz propA, propB propC and propD. I want to write a condition with OR checking more than one parameter like below. {@if cond="'{obj.propA}'.length > 0 || '{obj.propB}'.length > 0 ||…
Sripaul
  • 2,227
  • 9
  • 36
  • 60
1
vote
1 answer

Regex comparison in Dust

Is there a way to use regex expression comparison using dust template. eg: @select key="{notes}"} {@eq value="s+"} sample: {notes} {/eq} {@default} {notes} {/default} {/select} I want any…
Abha
  • 21
  • 1
1
vote
1 answer

Dust.js get call count of helper in template

So I have a dust.js helper which requires some jsx module when called and afterwards renders this module as html (some kind of plugin). {@react type="Text"\} ... ... {@react type="Text"\} {@react type="Text"\} Meanwhile I have a data…
d2uX
  • 241
  • 2
  • 14
1
vote
2 answers

DustJS logic to verify empty string

I need to write logic to check whether the value is empty or it has string. Any help on this.. i tried this following. but it doesn't work in nodejs and throwing error {@if cond="'{notes}' != '' || '{errors}' != '' "} display html {/if}
0
votes
1 answer

Dustjs - Check condition regarding ALL items in an array with dustjs template

So I'm having trouble with a Dust.js template. Suppose I have these example object models: var lifeStory = [{ "LifeEvent": "Birth", "year": "1963" }, { "LifeEvent": "marriage", "year": "1963", …
RayLoveless
  • 19,880
  • 21
  • 76
  • 94
0
votes
1 answer

Accessing outer AND inner indexes inside nested arrays at the same time

I've got nested arrays such as: "outer" : [ { "inner": [ {}, {} ] }, { "inner": [ {}, {} ] } ] I neeed…
0
votes
1 answer

Dustjs OR helper

How to write below statement using dust helper? {@eq key="device" value="windows || Linux"} Your system is Windows or Linux based. {:else} Your system is MAC based. {/eq}
user3380358
  • 143
  • 1
  • 7
0
votes
1 answer

Use node module in typescript environment

I've been trying to use the node modules 'markdown' and 'dustjs-helpers' in my angular 2.0 client side. The thing is that I couldn't reach a solution using typings (both packages are not available on typings) and I wonder if there is a way to use…
Mochics
  • 57
  • 1
  • 7
0
votes
1 answer

compare multiple JSON keys against same value in dust templates

I have a JSON being passed to a Dust template and want to compare multiple keys for the same value. For example I have a JSON like: "data": { "abc": "true", "xyz": "true", "uno": "true" } Is there a way apart from using "IF"…
Gautam
  • 108
  • 8
0
votes
1 answer

Using the dustmotes-if helper

I am loading (via requirejs) (the latest versions of) dust and dust-helpers in the following way define.amd.dust = true; require(["./Scripts/dust-full"], function (dust) { require(["./Scripts/dust-helpers"], function () { ... //my other…
0
votes
1 answer

Dust.js Template Custom Helper in Bootstrap Inconsistent Behaviour

I have a Dust.js helper where I apply some acl logic as follows: 'use strict'; import dust from 'dustjs-linkedin'; import acl from '../config/acl'; dust.helpers.accessControl = function(chunk, context, bodies, params) { let userId =…
Hasan Can Saral
  • 2,950
  • 5
  • 43
  • 78
0
votes
1 answer

How to use dustjs-helpers with grunt-dust?

I'm using grunt-dust to compile dustjs templates, but now I've run into the problem that I need to use dust helpers (like @eq) which apparently grunt-dust ignores completly. I've installed dustjs-helpers over npm but just can't figure out how to…
Katai
  • 2,773
  • 3
  • 31
  • 45
0
votes
1 answer

DustJS: Render partial via a Helper

I'm trying to abstract some code and would like to take advantage of dust.helpers to render a parial. My current setup: {> "includes/components/link" /} My ideal setup: {@uiComponent name="link" /} My helper: dust.helpers.uiComponent = function…
peduarte
  • 1,667
  • 3
  • 16
  • 24
1
2