Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can $context be acessible in Template? #79

Open
macedd opened this issue Aug 1, 2014 · 5 comments
Open

Can $context be acessible in Template? #79

macedd opened this issue Aug 1, 2014 · 5 comments

Comments

@macedd
Copy link

macedd commented Aug 1, 2014

A use case needs to have the whole context in a variable. Is it possible currently?

{{ context.length }}
{% for k,v in context %}
@speedmax
Copy link
Owner

speedmax commented Aug 1, 2014

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.

@macedd
Copy link
Author

macedd commented Aug 4, 2014

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 %}

@macedd
Copy link
Author

macedd commented Sep 19, 2014

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

@macedd
Copy link
Author

macedd commented Oct 14, 2014

Example 2: to render a sub-template with the same context

{% render 'app/table.html', context %}

@speedmax
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants