linkedin / dustjs

Asynchronous Javascript templating for the browser and server
http://dustjs.com
MIT License
2.91k stars 478 forks source link

Support generating inline partial blocks in a list #77

Open vybs opened 12 years ago

vybs commented 12 years ago

Child template

{>base_template/}
  {#loop}
          {<"var_{$idx}"}
          {/"var_{$idx}"}
  {/loop}

Base template

  {#anotherloop}

          {+"var_{$idx}"}

  {#anotherloop}

for instance looping a list of items and each iteration of the item in a child template creates a different inline partial block ,

so this means a array.list of inline partial blocks can be created as we iterated.

Once created, we can reference the indexed inline partial block in the base template

is this good?

rragan commented 12 years ago

What follows on from this defining of a number of inline params in terms of the use cases you are imagining?

vybs commented 12 years ago

@rragan updated the description to be more precise.

rragan commented 12 years ago

So this is a way to turn an array of things into a series of variable values that can be accessed by index? E.g not a true array anymore,

Ignoring the technical difficulty with dynamic inline partials (since the compiler binds them at build time but you want to resolve them at run time), I still don't see the value -- assuming the technical issues can be overcome? It seems like if we want variable and array storage dynamically created at runtime, then we should explore that. Of course, that is another step towards making dust a programming language rather than a templating language.

vybs commented 12 years ago

is n't this simply extending dynamic partials concept. ? If partials can be invoked dynamically , why not inline partials. Not sure if this is possible with current implementation, since @jairodemorais did try and succeed partially.

rragan commented 12 years ago

@jairodemoraishttps://github.com/jairodemorais and I had a long chat and didn’t find a way around the technical issues given the current handling of inline partials at compile time and how to make them dynamic at runtime. Dynamic partials are resolved at runtime, but inline partials are processed at compile time in the current implementation making them pretty different even though they look similar on the surface of things.

From: Veena Basavaraj [mailto:notifications@github.com] Sent: Tuesday, September 04, 2012 10:35 AM To: linkedin/dustjs Cc: Ragan, Richard Subject: Re: [dustjs] Support the inline partial blocks as well to be dynamic (#77)

is n't this simply extending dynamic partials concept. ? If partials can be invoked dynamically , why not inline partials. Not sure if this is possible with current implementation, since @jairodemoraishttps://github.com/jairodemorais did try and succeed partially.

— Reply to this email directly or view it on GitHubhttps://github.com/linkedin/dustjs/issues/77#issuecomment-8271787.

jairodemorais commented 12 years ago

@vybs

@rragan is right! the only way is resolving the key at runtime, I have developed a first approach you can take a look here:

https://github.com/jairodemorais/dustjs/tree/DynamicInline