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

Fixes #3535: Syntax changes #3978

Merged
merged 2 commits into from
Jun 20, 2014
Merged

Fixes #3535: Syntax changes #3978

merged 2 commits into from
Jun 20, 2014

Conversation

samdark
Copy link
Member

@samdark samdark commented Jun 20, 2014

  • Removed form_begin, form_end
  • Added use() and ViewRenderer::uses that are importing classes and namespaces
  • Added widget dynamic functions *_begin, *_end, *_widget, widget_end
  • Added more tests

- Removed `form_begin`, `form_end`
- Added `use()` and `ViewRenderer::uses` that are importing classes and namespaces
- Added widget dynamic functions `*_begin`, `*_end`, `*_widget`, `widget_end`
- Added more tests
@samdark samdark added this to the 2.0 RC milestone Jun 20, 2014
@samdark samdark self-assigned this Jun 20, 2014
@samdark
Copy link
Member Author

samdark commented Jun 20, 2014

#3535, #3971

This was referenced Jun 20, 2014
*/
public function getName()
{
return 'Twig Extension for Yii 2';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is allowed name, but I think it should be some kind of identifier because it's used later to access the extension in template: $this->env->getExtension('Twig Extension for Yii 2')->registerAsset($context, "app");

samdark added a commit that referenced this pull request Jun 20, 2014
@samdark samdark merged commit 28b6bc5 into master Jun 20, 2014
@samdark samdark deleted the twig-syntax-changes branch June 20, 2014 09:34
@cansozeri
Copy link

Hi if we use extend in our template site. The use parameter gives this error .. So we have to add this code to our main layout page, but I just want to use it in one page, if I add this main layout it will be called every page .. Is this a normal behaviour ??

user.htm extends main.htm

{% extends "main.htm" %}
{{ use('yii\grid\GridView') }}

The error is

A template that extends another one cannot have a body

But if I add 'use' in main.htm it works.

@samdark
Copy link
Member Author

samdark commented Jun 20, 2014

I don't quite understand how to reproduce the issue.

@cansozeri
Copy link

First extend another file in twig for example from index.htm extend main.htm

Main.htm is our main layout .. It has body and other functions in it ..

{{ this.beginPage() }}
<!DOCTYPE html>
<html lang="{{app.language}}">
<head>

</head>
<body>


        <div class="container">

        {%block body%}

        {%endblock%}
        </div>

        <footer class="footer">
        <div class="container">

        </footer>

    </div>
{{ this.endBody() }}
</body>
</html>
{{ this.endPage() }}

in index.htm

{% extends "main.htm" %}
{{ use('yii\grid\GridView') }}

{%block body%}
<div class="user-index">

</div>
{%endblock%}

If I use it like this I get the error..

A template that extends another one cannot have a body ...

@cansozeri
Copy link

@samdark can you reproduce the issue ??

@samdark
Copy link
Member Author

samdark commented Jun 21, 2014

Not yet. Would be cool if you'll create a separate ticket for it because it's easy to lose track of issues in closed tocket.

@tvdavid
Copy link
Contributor

tvdavid commented Jul 8, 2014

@cansozeri Try moving the use() statement within a {%block%}, that way it works fine. I agree that it would look cleaner if use statements in child templates could be placed on top of the file, but that's probably a twig limitation?

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

Successfully merging this pull request may close these issues.

4 participants