J
J
jacksparrow2015-12-09 17:01:14
Yii
jacksparrow, 2015-12-09 17:01:14

What is the correct twig main layout for Yii2 basic?

When connecting the template engine to yii2, there were questions about the main layout
Default example

{{ register_asset_bundle('app/assets/AppAsset') }} 
    {{   void(this.beginPage()) }}
    <!DOCTYPE html>
    <html lang="{{ app.language }}">
        <head>
            <meta charset="{{ app.charset }}">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <title>{{ html.encode(this.title) }}</title>
            {{ html.csrfMetaTags | raw }}
            {{   void(this.head) }}
        </head>
        <body>
            {{   void(this.beginBody()) }}
           ....

There is a line break in it, how to fix it?
take.ms/gI40m The
question also found several options, which one is correct
{{   void(this.endPage()) }}
 {{  this.endPage()|raw }}
 {{  this.endPage() }}

Added:
// line 1
        $this->env->getExtension('yii2-twig')->addUses("yii/web/JqueryAsset");
        echo "
";
        // line 2
        $this->env->getExtension('yii2-twig')->registerAsset($context, "jquery_asset");
        echo "
";

gaps are created by these things

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
A1eksandr, 2015-12-09
@A1eksandr

Line breaks appeared most likely due to the fact that you added them to some included php file before <?php or after ?>, for example, in the controller. I won’t tell you about twig because I don’t use it.

A
Alexander Makarov, 2015-12-10
@SamDark

https://github.com/yiisoft/yii2-twig/blob/master/d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question