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 or Zephir - Phalcon Custom Blocks, Possible?

I am trying to create my own blocks or wrappers to apply to anything within Volt code, for example:

{% uglify %}
<script>
var x = 'a bunch of javascript here';
{% end %}

I know how to create custom:

  • Tags: {{ SomeModule::init(volt.value) }}
  • Filters {{ volt.value|random }}
  • Function: {{ random(volt.value) }}

Can I accomplish something like the above with inline JavaScript? {{ uglify(' window.x = { param: 'param.from['volt']', deeper: { more: 'param.from['volt2']` } } ') }}

Is that crazy? Maybe I should just have an external JS file and run it through there? This is a strange case for what Im doing I suppose any thoughts would be appreciated :)

Furthermore, Zephir is absoltely awesome. I was looking in the CPhalcon repository all I could find was this below, if this is the correct item:

The code looks like this below and it seems that Block Statements are only {% block name %}...{% endblock %}, nothing customizable I don't think. This is a feature Django has with Django Pipelines.

            if type == PHVOLT_T_ELSEFOR {
                let compilation .= "<?php $" . prefixLevel . "iterated = false; ?>";
                let forElse = prefixLevel;
                let this->_forElsePointers[level] = forElse;
                break;
            }