Ticket #36 (closed enhancement: fixed)

Opened 3 months ago

Last modified 3 months ago

Inner text on partial views

Reported by: torkelo Assigned to:
Priority: major Component: Spark Core
Keywords: Cc:

Description

Would it be possible to send the inner text to a partial?

For example lets say we have a partial named _text.spark

<text key="my_text_key">

some inner text to send to the partial view, in this case the default text for this text key.

</text>

If would be nice to have the inner text be available in the partial as a locally scoped variable (for example innerText).

Then the _text.spark partial could look like this:

<viewdata translationLookup="TextTranslationLookup?" />

<span> ${translationLookup.Find(key, innerText)} </span>

This is just a simple example, I think this could be useful in some cases.


Louis: That's a really interesting idea. I wonder how hard it would be to have the inner content sent forward into the partial as code. It could make a partial act a bit more like monorail view components that use render section.

Although in your case it sounds like a string would be more convenient.

Change History

08/10/08 18:09:49 changed by louis.dejardin

  • status changed from new to closed.
  • resolution set to fixed.

The implementation ended up being a bit different, but I believe it's a very powerful feature.

You can now use the <render/> element inside a partial file. This will generate inline all of the child content in the partial element from the parent template.

example partial file _Rounded.spark

<div class="roundbox" title="${tooltip}">
  <img src="~/etc">
  <render/>
  <img src="~/etc">
</div>

example view file Index.spark

<p>blah blah</p>
<Rounded tooltip="'hi'"><p>hello world</p></Rounded>
<p>blah blah</p>

The ability to capture to a variable has been added to get inner text as string. In a partial you would have:

<content var="innerText"><render/></content>