Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass twig variable to octobercms component

Tags:

octobercms

Here is my code block, I want to pass the service variable to component.

{% for service in services %}
    <div data-service="#development" 
        class="col-md-4 col-sm-6 wow fadeInUp" 
        data-wow-duration="300ms" 
        data-wow-delay="0ms"
    >
        <div class="media service-box">
            <div class="pull-left">
                <i class="fa fa-line-chart"></i>
            </div>
            <div class="media-body">
                {% component 'editable' file={{ service }} %}
            </div>
        </div>
    </div><!--/.col-md-4-->
{% endfor %}

Thanks,

like image 839
Sophy SEM Avatar asked Dec 06 '25 03:12

Sophy SEM


1 Answers

Inside {% .. %} directives you can simply use twig variable names without the double curly braces {{ .. }} around them. The {{ .. }} braces just designate twig expressions wheras {% .. %} designates twig statements. See twig templating documentation. Inside both twig variables can be simply accessed by their names.

So here you could just do like

{% component 'editable' file=service %}
like image 187
trollkotze Avatar answered Dec 12 '25 11:12

trollkotze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!