Closed teliosdev closed 8 years ago
Wouldn't this be a better fit for the context shorthand syntax?
Alternatively, if you want to have a single presenter (e.g. if you're using a single partial template) just use underscore instead of dot?
def article_name ... end
def article_posted ... end
I'm not sure I understand the dot syntax in the first place - why is it that the syntax for passing a single argument to the method is a dot ({{ article.name }}
)? Why specifically that syntax?
There's a historical reason for it – it provides a level of compatibility with a subset of Liquid that was used at Zendesk. Specifically, we had the notion of "dynamic content" which were user managed translation strings. You'd reference them by their key, e.g. {{dc.frontpage.welcome}}
. Hence, the argument is dynamic and resolved at runtime. The :
operator is strongly typed and thus better suited for what you're trying to do. It also automatically works with the presenter system.
I find myself doing things like this often:
I think it looks excellent on the template. But when you go over to the presenter, it looks like this:
This is not so excellent. I was wondering if you would be welcome to a class method to make it easier to create such methods. It would look something like this:
I'd be happy to write the code for it, but I'm just wondering what you think before I go ahead with it.