tags:

views:

154

answers:

1

I'm going a little nuts trying to figure out how to use template inheritance in Haskell's HStringTemplate. Basic template usage is easy enough, but missing something inheritance is concerned. Can anyone point me in the direction a decent example? The document below just isn't complete enough to graduate to more advanced usage.

http://www.haskell.org/haskellwiki/HStringTemplate <-- No help!!

+1  A: 

Ok finally figured it out. You wouldn't belive how long I've been staring at the Hackage docs, trying to piece this together. Here's a contrived example, for those of you who follow:

let p = newSTMP "Parent --> $child()$" :: StringTemplate String
let c = newSTMP "Child --> Your content Here." :: StringTemplate String

let grp = groupStringTemplates [("parent", p),("child", c)]

putStrLn $ toString $ fromJust $ getStringTemplate "parent" grp

This prints:

Parent --> Child --> Your content Here.

I'll add that I think some of my difficulty has to do with the fact that I'm not all that familiar with Java's StringTemplate. I'm still not sure to what degree Haskell's package emulates Java's.

Shaun