Heist 0.11 Questions

60 views
Skip to first unread message

Luke Hoersten

unread,
Apr 30, 2013, 10:50:56 PM4/30/13
to snap_fr...@googlegroups.com
Hello,

I've updated to Heist 0.11 and the semantics seemed to have changed a bit and so I have a couple questions:

  1. Are unbound splice contents still removed from the final document? It seems they are not. I have cases where attributes still have "${tag}" in the final document.

  2. I was doing something like:
  <dfIfChildErrors ref="name">
    <bind tag="name-error">error</bind>
  </dfIfChildErrors>

In previous versions of Heist, "${name-error}" would remain unbound if "dfIfChildErrors" didn't bind to anything. Now it seems that's not the case. 

Hopefully there are still ways to handle these cases. I've also upgraded to the latest D-F so perhaps some of the issue lies there as well?

Thanks,
Luke

MightyByte

unread,
May 2, 2013, 1:55:33 AM5/2/13
to snap_fr...@googlegroups.com
To question 1, you are correct.  The semantics did change from the way Heist used to do things.  When I was implementing compiled splices it became obvious that attribute splice processing should be idempotent when no splices are bound.  I'm convinced that the previous behavior was wrong.

I'm not sure what to suggest for your dfIfChildErrors situation.  I think it's only a function of the new idempotent behavior.  I don't know of any issues with the last D-F-Heist, but I'm certainly open to API additions if that's what we need to do to support practical use cases.


--
 
---
You received this message because you are subscribed to the Google Groups "Snap Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snap_framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Luke Hoersten

unread,
May 2, 2013, 10:46:25 AM5/2/13
to snap_fr...@googlegroups.com
#1 makes sense. I was only using the unbound tag behavior to mean empty tag in a specific case (setting what page is active in the nav bar). I think the Snap website uses JS to do this and I may take the same approach.

#2 Relevant code for reference:

  <dfIfChildErrors ref="name">
    <bind tag="name-error">error</bind>
  </dfIfChildErrors>

The motivation for the example code was the issue that dfIfChildErrors uses an attribute "ref" to check the state of the respective form element for errors. This means dfIfChildErrors can't be used as an attribute tag. For example, "${dfIfChildErrors ref="name"}" is not valid heist syntax AFAIK. So I basically used the conditional splice to bind a new tag with a hard-coded name ("name-error" in this case) and then use that in the form element like "<fdInputText class="${name-error}">" which would bind to the CSS class "error" if there was an error.

Perhaps there's a better way to do this. I'm certainly open to suggestions. I was on a plane with no internet when I coded it so I couldn't look things up =). That said, the issue still stands that it seems if there are no errors in the respective form, dfIfChildErrors should remove the "<bind tag="name-error">error</bind>" from the DOM and then the bind would not be processed later on. If the splice binding is always applied to the DOM in the same order, it could still be idempotent and work for this case.

What are your thoughts?

Luke

MightyByte

unread,
May 8, 2013, 4:02:45 PM5/8/13
to snap_fr...@googlegroups.com
I'm aware that the whole splice abstraction simply doesn't work as well for inserting things into attributes.  I haven't come up with a really good way around that because the type of an attribute's value is simply not the same as the type of the contents of a tag.  We could add more complexity to the ${} syntax to support that, but I'm not a big fan of that approach.

I guess for the specific case of df-heist, one solution would be to make an "else clause" tag called dfIfChildNoErros (or something similar) so that you could bind your tag to the empty string if there were no errors.  I imagine Jasper would probably accept a patch for that.

MightyByte

unread,
May 10, 2013, 3:20:19 PM5/10/13
to snap_fr...@googlegroups.com
Ok, I think I figured out what's going on here.  Luke is using interpreted splices.  In 0.10, all of the built-in splices became load time splices.  Load time splices are like interpreted splices except they are processed at load time before anything else happens.  I had to do it this way because it turns out that the composable nature of interpreted/load-time splices is crucial to getting the expected behavior of the built-in splices.  They can't work as compiled splices, so I set the Heist snaplet to bind them as load time splices by default.  This is the correct thing to do when you're using compiled splice mode.  However, when you're using interpreted mode you don't need this because you can just make them be interpreted splices.

The bind is getting bound even when the body of dfIfChildErrors is not executed because the bind splice is being processed as a load time splice.  I believe this will be fixed if the heist initializer is changed to the following:

nestSnaplet "heist" heist $ heistInit' "templates" $ mempty { hcInterpretedSplices = defaultInterpretedSplices }

Luke Hoersten

unread,
May 10, 2013, 9:58:15 PM5/10/13
to snap_fr...@googlegroups.com
mempty { hcInterpretedSplices = defaultInterpretedSplices }

Did indeed fix it. Thanks Doug!
Reply all
Reply to author
Forward
0 new messages