-
Notifications
You must be signed in to change notification settings - Fork 479
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
Issue : GH-266 store rendered template in global does not work for partials.! #292
Comments
Curious, what do you need the names for? Debugging? If it is only debugging, maybe there should be a build option so we don't pay this cost all the time. |
name of helper, i guess we have to inject it in the compiler. Here is our i18n helper we use for looking up strings on the client/browser, we CDN the translated strings Third, the number of i18n strings in our templates accounts to >50% of the markup.
|
Prefer $ names for consistency Sent from my iPhone On Jun 23, 2013, at 5:14 PM, "Veena Basavaraj" <notifications@github.commailto:notifications@github.com> wrote: name of helper, i guess we have to inject it in the compiler. Here is our i18n helper we use for looking up strings on the client/browser, we CDN the translated strings dust.i18n = dust.i18n || {}; /**
— |
thanks, will send a PR for this change ( so I assume we are ok with storing a array of visited templates with push and pop. Is there a way to expose peek() on arrays in JS in a neat way? rather than doing array[array.length -1]? |
shift/unshift and ref first element. Not sure how perf compares with push/pop Sent from my iPhone On Jun 23, 2013, at 6:08 PM, "Veena Basavaraj" <notifications@github.commailto:notifications@github.com> wrote: thanks, will send a PR for this change ( so I assume we are ok with storing a array of visited templates with push and pop. Is there a way to expose peek() on arrays in JS in a neat way? rather than doing array[array.length -1]? — |
stack vs queue push/pop is faster. |
Not sure how critical name of helper is. The code in the helper knows its own identity and if it calls partials the name changes anyway. Just asking to trigger thinking about it. Rich From: Veena Basavaraj [mailto:notifications@github.com] name of helper, i guess we have to inject it in the compiler. Here is our i18n helper we use for looking up strings on the client/browser, we CDN the translated strings dust.i18n = dust.i18n || {}; dust.i18n.cache = dust.i18n.cache || {}; /**
dust.helpers.i18n = function(chunk, context, bodies, params){ if(params && params.hide === 'true'){ // do not render return chunk; } if(params && (typeof params.key !== 'undefined')){ var key= params.key,
var templateName = overrideTemplateName || currentTemplateName; if(typeof templateName !== 'undefined') {
} return chunk; } }; })(); — |
not sure I understand, second this is our internal helper on how we do i18n, the helper name and the i18n string cache are different objects. can you elaborate more? |
It was just a question to make us think about completeness. If we want to know name of initial template while it runs or current partial while it runs, do we want to know name of currently running helper within the helper. My take is no -- especially based on your i18n because the helper name would hide the name of the partial/template it was being used in. |
GH-292 support template name in nested partials, need a stack to store the current name
add support for GH-292, support the template name in nested partials
Too bad that the context.global__template_name__ does not reflect the partial name.
Hence the fix is to store a stack of template names and push/pop and in the helpers do a peek() to get the current template.
the fix is simple to push the current template elem in chunk.partial and pop it off before returning from the function call.
#274
@rragan your thoughts.? also should I change the template name to be $template_name to be consistent?
The text was updated successfully, but these errors were encountered: