h2o-php
h2o-php copied to clipboard
Can $context be acessible in Template?
A use case needs to have the whole context in a variable. Is it possible currently?
{{ context.length }}
{% for k,v in context %}
Interesting idea, I don't think the context object should be exposure inside the context object. (If that makes any sense)
May be expose some of meta data that describe the context object. Ex. Length, stack...
Can you explain further what is the actual use cases?
Sent from my iPhone
On 2 Aug 2014, at 1:22 am, Thiago Fernandes [email protected] wrote:
A use case needs to have the whole context in a variable. Is it possible currently?
{{ context.length }} — Reply to this email directly or view it on GitHub.
Actually cant find exactly how it would be usefull.. sorry. I ended implementing the template in another way.
In the time what looked feasible was to pass a context
variable which had the other ones, by ref.
Your idea of Length and Stack would solve (on my mindset) if Context Resolver could handle dynamic variable names, like {% for var in context.stack %} {{ :var }} {% endfor %}
Example 1: To encode the context (a query) into json
- so easily pass data to the next page
- make javascript decisions uppon the context
- no need to print each field and control their additions
Example 2: to render a sub-template with the same context
{% render 'app/table.html', context %}
You can checkout the include tag that uses the current context.
On 15 Oct 2014, at 5:52 am, Thiago Fernandes [email protected] wrote:
Example 2: to render a sub-template with the same context
{% render 'app/table.html', context %} — Reply to this email directly or view it on GitHub.