[Snap Framework] renderTemplate with XML fragments in Heist

Kevin Jardine kevinjardine at yahoo.com
Thu Jun 17 11:00:05 CDT 2010


One experiment that I'm looking at is defining:

klugeSplice :: [(B.ByteString,[Node])] -> Splice MyMonad
klugeSplice nodeDict = do
    input <- getParamNode
    let name = getName input
    return $ fromMaybe [Text (B.pack "oops")] $ lookup name nodeDict

and passing

(klugeSplice nodeDict) as the first parameter to bindSplice.

At least that function compiles but I'm afraid that I'm still lost in a conceptual sea so I'm not sure if this is anything like the best approach.

Kevin

--- On Thu, 6/17/10, Kevin Jardine <kevinjardine at yahoo.com> wrote:

> From: Kevin Jardine <kevinjardine at yahoo.com>
> Subject: Re: [Snap Framework] renderTemplate with XML fragments in Heist
> To: snap at snapframework.com
> Date: Thursday, June 17, 2010, 5:05 PM
> To explain in more detail, I had
> thought that Heist was a "slave" template library.
> 
> You hand it some attributes (nodes or strings) and a
> template name and it hands you back something (nodes or a
> rendered string).
> 
> Currently, however, it seems as though Heist is the master
> app and mine ends up being the slave - you hand Heist a page
> shell and define some hooks and it does all the work and
> hands you the final string.
> 
> Is that correct?
> 
> If so, I'm still keen to use the library but will have to
> rethink how I am doing things as the work flow is in essence
> in the reverse order of what I am used to.
> 
> Kevin
> 
> --- On Thu, 6/17/10, Kevin Jardine <kevinjardine at yahoo.com>
> wrote:
> 
> > From: Kevin Jardine <kevinjardine at yahoo.com>
> > Subject: Re: [Snap Framework] renderTemplate with XML
> fragments in Heist
> > To: "MightyByte" <mightybyte at gmail.com>
> > Date: Thursday, June 17, 2010, 4:34 PM
> > Thanks for your patience here!
> > 
> > I am still running into a conceptual difficulty here
> as I
> > want to pass around a dictionary/map structure of some
> kind
> > of attribute value pairs.
> > 
> > Eg. [(String, [Node])] or [(String,String)] which I
> can
> > manipulate in my own monad and then pass to Heist when
> and
> > if I choose.
> > 
> > But bindSplice takes a function where I would want a
> > dictionary.
> > 
> > I am obviously lacking in Heist-foo.
> > 
> > What to do?
> > 
> > Kevin
> > 
> > --- On Thu, 6/17/10, MightyByte <mightybyte at gmail.com>
> > wrote:
> > 
> > > From: MightyByte <mightybyte at gmail.com>
> > > Subject: Re: [Snap Framework] renderTemplate with
> XML
> > fragments in Heist
> > > To: "Kevin Jardine" <kevinjardine at yahoo.com>
> > > Date: Thursday, June 17, 2010, 3:55 PM
> > > Yeah, this was our intent. 
> > > renderTemplate is the only way to get
> > > things out of TemplateMonad.  By using
> bindSplice as
> > I
> > > mentioned
> > > above, you keep your data is structured nodes
> when
> > > possible.
> > > bindStrings is only intended as a convenient way
> to
> > pass
> > > strings into
> > > templates.
> > > 
> > > On Thu, Jun 17, 2010 at 9:47 AM, Kevin Jardine
> <kevinjardine at yahoo.com>
> > > wrote:
> > > > Or am I making a conceptual error here?
> > > >
> > > > Perhaps I should be using runTemplate to get
> the
> > XML
> > > fragments and only use renderTemplate at the very
> top
> > > level?
> > > >
> > > > This would keep the input as structured
> nodes
> > and
> > > convert to bytestrings only at the last step.
> > > >
> > > > Kevin
> > > >
> > > > --- On Thu, 6/17/10, Kevin Jardine <kevinjardine at yahoo.com>
> > > wrote:
> > > >
> > > >> From: Kevin Jardine <kevinjardine at yahoo.com>
> > > >> Subject: renderTemplate with XML
> fragments
> > in
> > > Heist
> > > >> To: snap at snapframework.com
> > > >> Date: Thursday, June 17, 2010, 3:38 PM
> > > >> If I call
> > > >>
> > > >> renderTemplate (bindStrings dict
> > > emptyTemplateState)
> > > >> templateName
> > > >>
> > > >> this works fine if the dict values are
> all
> > > unstructured
> > > >> data.
> > > >>
> > > >> However, if they are XML structures,
> the
> > resulting
> > > HTML is
> > > >> escaped, presumably because bindStrings
> > inserts
> > > them as Text
> > > >> nodes.
> > > >>
> > > >> What function instead of bindStrings do
> I
> > call to
> > > insert
> > > >> XML fragments?
> > > >>
> > > >> Kevin
> > > >>
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > >
> > > >
> _______________________________________________
> > > > Snap mailing list
> > > > Snap at snapframework.com
> > > > http://mailman-mail5.webfaction.com/listinfo/snap
> > > >
> > > 
> > 
> > 
> > 
> > 
> 
> 
> 
> 


      


More information about the Snap mailing list