jjn1056 / Template-Pure

Logic-less, markup driven HTML templates inspired by pure.js
2 stars 2 forks source link

Template::Pure::Result #4

Open jjn1056 opened 8 years ago

jjn1056 commented 8 years ago

One thing that comes up is that I'd like to build up transforms to a template over several calls to a render like method. That way if you have a transform pipeline you can avoid the need to maintain a state object.

Perhaps we could have a type of result intermediate class:

my $result = Template::Pure->document(
  template => $template,
  directives => \@directives);

$result = $result->process($data, \@extra, @args);
$result = $result->process($data, \@extra, @args);

...

and then

my $html = $result->render;

jjn1056 commented 8 years ago

the thing that makes me think about this is that in Catalyst we have chaining which is great but since we bust up the pipeline over several actions we end up using stash or similar to maintain state and then we have to send the full state all at once to the view. Part of me would like to build up the view in steps across each action in the chain. That way we can avoid being forced to maintain state just for the reason of giving it all to the view at once and we can also call methods on the view rather than passing data (which I think is a win since I think its preferable when doing object oriented programming to deal in methods not data...)