Pass template as string to Spark, return transformed template as string

2 views
Skip to first unread message

scalvert

unread,
Nov 16, 2009, 11:22:54 AM11/16/09
to Spark View Engine Dev
Currently our application uses NVelocity to pass a template as a
string, coupled with a Dictionary, and have it return the transformed
template as a string. Is this possible to do with Spark.

The direct usage samples seem to be adding a template dynamically, but
it still points to a file. I need to be able to pass a string instead
of a filename.

scalvert

unread,
Nov 18, 2009, 10:47:29 PM11/18/09
to Spark View Engine Dev
Anyone...anyone?

Artem Tikhomirov

unread,
Nov 20, 2009, 8:09:26 AM11/20/09
to spar...@googlegroups.com
It's a bit hard to do, but possible. You should use InMemoryViewFolder to register path to  template string dictionary, then set it to SparkViewEngine.ViewFolder property.

After that you should feed your view data coupled with a path string to the engine. See lou's blog: http://whereslou.com/2008/12/16/using-spark-as-a-general-purpose-template-engine

On Thu, Nov 19, 2009 at 6:47 AM, scalvert <steve....@gmail.com> wrote:
Anyone...anyone?

--

You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=.



KevM

unread,
Nov 20, 2009, 11:47:34 AM11/20/09
to Spark View Engine Dev
This approach worked for me. Here is a paste of my wrapper for Spark
that does I believe this is close to what you are looking for.

http://gist.github.com/239611

Notice that I had to hash the view string for use as a template name
because it seems there is a singleton like bug or a feature that
causes templates with the same name still exist to across spark
engines.

Kevin Miller

On Nov 20, 7:09 am, Artem Tikhomirov <ar...@tikhomirovs.ru> wrote:
> It's a bit hard to do, but possible. You should use InMemoryViewFolder to
> register path to  template string dictionary, then set it to
> SparkViewEngine.ViewFolder property.
>
> After that you should feed your view data coupled with a path string to the
> engine. See lou's blog:http://whereslou.com/2008/12/16/using-spark-as-a-general-purpose-temp...
Reply all
Reply to author
Forward
0 new messages