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
dust.load -> internal breaks users of the old API #640
Comments
(also: can have semver? Please?!) |
Yeah... that's why If monkey-patching is inevitable, does it make sense to move it to the render layer or a |
(The semver thing is some sort of legacy at LinkedIn that I haven't been able to push past-- FWIW Dust versioning is "minor adjusts API, major adjusts template API") |
So what you really need is the ability to hot-plug different |
(incidentally, just making |
Ideally, I feel like you build your middleware into |
Actually, after proving the concept, I was planning on trying to get dustjacket integrated, or something with its concepts. The specific goal I have is breaking the 1:1 template name to template mapping. The problem with doing it in onLoad is the caching behavior. You can't do internationalization that way, and having a central place to do the mapping from the language-agnostic render() calls to the specific templates is super useful, rather than pushing that complexity into all the call sites. |
Patching render might be the next best thing for me at this point -- it's the actual outside API where the name passed to load is used. |
So template names are actually divorced from cache now. You can compile a template with no name: And render a template with no name: And register that template under any name you want... Does it maybe make sense in your My adaro-fu is weak and reading the code where middleware is added is not as useful probably as seeing it actually be used somewhere. |
Yeah, that's a possibility. not as clean as a stateless mapping though. https://github.com/krakenjs/dustjacket/blob/v2.x/index.js is where the middleware gets added. |
At its core, though, the API is usually |
So if it's a name, look it up in Can you elaborate on how a single template name might result in two different templates? Can it result in different templates in the same instance of a running server? The name lookup is dynamic every time? Is it something like |
Yeah, the cache is used, but under the expanded name, not the shorter. Each new render does the lookup afresh.
Invalid values of lang, or unsupported ones would render |
Actually just looked at the new load ... my monkey patch would actually still work. It maintains the same outside contract and replaces load wholesale. |
Short-term, it seems to make sense to have a Going forward, I think enhancing |
I'll start working that direction then. Context-awareness first, that's the core point. And letting |
Oh, the only problem there: |
Hmm, you're right.
|
OK, as a less-drastic first step here's what I'm working on: Currently I'm going to add a third signature, which is I hope that will be the first step to making your life a little easier. |
Absolutely! I was actually preparing a pull request to that effect just today -- I'd complete that tomorrow if you want to leave it to me. |
(only slow part was learning the intricacies of the test suite) |
Oop I immediately started writing after I posted without checking for replies. I'll put up what I have so far instead of finishing it and you can take a look. |
https://github.com/linkedin/dustjs/pull/641/files feel free to incorporate or not and let's make sure this fits your use case. It won't be the end-all, but maybe a good stopgap. |
Cool. Lemme see! |
Closed in #641 |
I was doing untoward hacks, replacing dust.load in
dustjacket
for internationalization purposes, and this being private now makes that impossible.onLoad
isn't rich enough for my purposes, which otherwise require doing unbelievably ugly things in the cache.The text was updated successfully, but these errors were encountered: