passing bound names to splices #7

Closed
sol opened this Issue Feb 11, 2011 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

sol commented Feb 11, 2011

When trying the following

<bind tag="foo">5</bind>
<fact><foo/></fact>

(here fact is bound to factSplice from the tutorial)

it seems that <foo/> is not expanded before the splice is evaluated (which in this case leads to an exception).

Do we want to support the above example? If no, is there a way to do something similar with heist? In particular I'd like to bind some name inside my code with bindString and pass it to a splice.

Member

cdsmith commented Feb 11, 2011

The contents are not pre-processed, but if you want to process them in factSplice, you can use runNodeList to do so. That's by design, since you may want to modify the template state prior to processing children.

Contributor

sol commented Feb 12, 2011

Nice, thanks. Using getParamNode_ instead of getParamNode with

getParamNode_ = getParamNode >>= runNodeListOnChildren
  where
    runNodeListOnChildren (X.Element t a c) = X.Element t a `liftM` runNodeList c
    runNodeListOnChildren node              = return node

works for me. Do you think it would be beneficial to add something like this to heist (or some other lib, e. g. snap)?

Owner

mightybyte commented Mar 20, 2011

Instead of your getParamNode_, wouldn't you want something more like this?

runParamNode = getParamNode >>= runNode

If this does what you want, it seems simple enough that I'm not inclined to include it as another function. Also, I just committed a new function runChildren to git which does something similar, but only renders the children. We'll probably release a new hackage version with this in the near future. If you have any other suggestions about this, it would be great to discuss them before this next release.

@mightybyte mightybyte closed this Oct 12, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment