How to output "{{" ?

Hi all,

I'm trying to output Handlebars templates in my Volt template, and I'm having a conflict because both systems use "{{ }}" as delimiters. Is there a way to turn off rendering by Volt in a block? Something like:

{% verbatim %} {{ name }} {% /verbatim %}



1.9k

You can extend the compiler with a function to render a partial as "raw". This is what I use:

view service

    $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);

    $volt->setOptions(array(
        'compiledPath' => __DIR__ . '/cache/',
        'compiledExtension' => '.php',
        'stat' => ( DEV ) ? true : false ,
        'compiledSeparator' => '_',
        'prefix' => 'compiled'
    ));
    $compiler = $volt->getCompiler();
    $compiler->addFunction('include_raw', function($resolvedArgs, $exprArgs) use ($view) {
        return sprintf('file_get_contents("%s" . %s)', $view->getViewsDir(), $resolvedArgs);
    });

    return $volt;

template

    <div class="container">
        {{ include_raw('index/index.volt') }}
    </div>

Thanks Jimmy!

Use {{ " .. " }}

      {{ "{{#each sales}}" }}
            <tr>
                <td>{{ "{{ id }}" }} <a href="/sale/edit/{{ "{{ id }}" }}">Edit</a></td>
                <td>{{ "{{ saleType }}" }}</td>
                <td>{{ "{{ price_base }}" }}</td>
        {{ "{{/each}}" }}