Aborting Processing

24 views
Skip to first unread message

Dave Glick

unread,
Apr 25, 2012, 8:50:10 AM4/25/12
to dotliquid
Hi,

I have two questions about aborting processing/rendering in the
engine. The first is that I'm wondering if it's possible at all. Since
I'll be allowing users to edit templates, I'd like a way to time them
out if they do something like trigger an infinite loop.

The second question I have (which might be answered by the first) is
if there's a way to abort processing from within a tag. I'd like to
provide some switches or "early exit" opportunities for template
authors (something like "this doesn't apply, so don't use this
template"). That would allow the template to serve a dual purpose as
both a template and, when appropriate, like a controller.

If aborting isn't available right now, I'd be happy to take a look and
submit a pull request. Any hints on where the most appropriate place
to put such functionality would be?

Thanks!

Tim Jones

unread,
May 20, 2012, 10:03:53 AM5/20/12
to dotl...@googlegroups.com
Hi Dave,

There's nothing in DotLiquid for this at the moment. That said, couldn't you use the TPL? Something like:

var task = Task.Factory.StartNew(() =>
{
	var template = Template.Parse("{{ user.name }}");
	return template.Render(...);
}); // Use a fixed amount of time, and just give up if we go over that. task.Wait(1000);

(By the way, thanks for your pull request! I hope to look at it soon.)

Tim
Reply all
Reply to author
Forward
0 new messages