Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
seriousManual opened this issue Mar 5, 2014 · 5 comments
Open

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

seriousManual opened this issue Mar 5, 2014 · 5 comments

Comments

@seriousManual
Copy link
Contributor

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

@kate2753
Copy link
Contributor

kate2753 commented Mar 7, 2014

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

@seriousManual
Copy link
Contributor Author

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.

@prashn64
Copy link
Contributor

By the filters module, do you mean this:

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

@seriousManual
Copy link
Contributor Author

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);

@peterbraden
Copy link

+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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants