dustjs-helpers icon indicating copy to clipboard operation
dustjs-helpers copied to clipboard

using helpers as well as filters in combination....

Open seriousManual opened this issue 11 years ago • 5 comments

...does not work, at least not in a commonJs environment as the bootstrapping function relies on a global available dust instance.

seriousManual avatar Mar 05 '14 11:03 seriousManual

@zaphod1984 sould you give a code example of how you are using them?

kate2753 avatar Mar 07 '14 04:03 kate2753

sure, no problem:

var dust = require('dustjs-helpers');

when requiring, the lib checks for a global available dust instance, if not available, it requires dust and exports it. (https://github.com/linkedin/dustjs-helpers/blob/master/lib/dust-helpers.js#L514) the filters lib just enhances dust if not in global context.

the filters module does the same. i do realize that both of the modules rely on dust being a singleton but it would be much nicer if both would behave the same and the enhancment with helpers and filters would be done in a more explizit way.

seriousManual avatar Mar 07 '14 08:03 seriousManual

By the filters module, do you mean this:

https://github.com/linkedin/dustjs-filters-secure

prashn64 avatar Mar 11 '14 00:03 prashn64

exactly.

a sane way without clobbering the global namespace would be something like this:

var dust = require('dustjs-linkedin');

require('dustjs-filters-secure').enhance(dust);
require('dustjs-helpers').enhance(dust);

seriousManual avatar Mar 11 '14 07:03 seriousManual

+1. The way that helpers currently works is nonsensical - if they are indeed helpers then they should augment dust, not just clobber it.

ie:

var dust = require('dustjs-linkedin');
require('dustjs-helpers')(dust)

peterbraden avatar Oct 01 '14 12:10 peterbraden