tbranyen / combyne

A template engine that works the way you expect.
MIT License
144 stars 19 forks source link

Support passing partials a filtered context object #58

Closed kadamwhite closed 9 years ago

kadamwhite commented 10 years ago

@tbranyen, here's my use-case: I have a partial that is used to render an article's banner image in a standardized manner. However, depending on the page, that image's context object may not be usable without pre-filtering. I could do something in the template, but I would prefer to be able to contextually transform the passed object based on the page context: something like this, e.g.

{%-- homepage --%}
{%each posts as post %}
<div class="post">
  {%partial post-banner post.image %}
</div>
{%endeach%}
{%--
category archive view: category.featured_image has a different structure
from post.image, and convert-image is used to produce a valid context object
--%}
{%each categories as category %}
<div class="category">
  {%partial post-banner category.featured_image|convert-image %}
</div>
{%endeach%}

I'd be curious for your thoughts; if this is valid, I'd appreciate a walkthrough of the code for this grammar, so that I could take a crack at a patch.

kadamwhite commented 10 years ago

@tbranyen I'm not going to have a chance to dive in on this or tbranyen/combynexpress#3 for the next few days -- if you want to pair up when I'm back from SF I'd love to get your help understanding the module's structure so that I could fix it myself, but if you have an opportunity to take a swing at either issue this week, I'll owe you a lunch at Saus :)

tbranyen commented 10 years ago

Sausy! I've got my hands full till maybe Wednesday, so I'll be able to dive in then :D

tbranyen commented 9 years ago

All set! Seems to work fine now :dancers: