We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt error PhalconException: Child templates only may contain blocks

when I try to add in some.html script tag throws this error --PhalconException: Child templates only may contain blocks-- add this tag because if I write javascript code in the block {% block on_ready %} the IDE not will syntax highlighting js that enter here .

   // index.html
    $(document).ready(function(){
        {% block on_ready %}{% endblock %}
     });
   // some.html
    {% extends index.html %}

    <script type="text/javascript">
       {% block on_ready %}
         console.log("test");
      {% endblock %}
    </script>

Thanks



98.9k

Code in child templates must be inside blocks:

{% extends index.html %}

{% block on_ready %}
    <script type="text/javascript">
        console.log("test");
    </script>
{% endblock %}
edited Mar '14

Hi

I've tried to do so as you say, but I throw an error in the js console Uncaught SyntaxError: Unexpected token < which I do not run the js code to enter on that block, seeing the code of the page this is the code that generates

   <script type="text/javascript">
      $(document).ready(function(){
          console.log("this block on ready index.html");

         //block on_ready
         <script type="text/javascript">
             console.log("this block on ready some.html")
        </script>
        //endBlock
     });
   </script>


98.9k

Then it must be:

{% block on_ready %}
    console.log("test");
{% endblock %}

but the IDE not will syntax highlighting js that enter here.



16.3k

I have the same problem. the above code i've tried and nothing sent to the view