Form theming and Symfony Collections - symfony

I wanted to add particular style to my CollectionType in twig and I received a solution here : Symfony/Jquery Collection of objects. Now I have a little problem that I can't solve :
I have this custom form_row :
// src/MyBundle/Ressources/views/CustomForms
{% block form_row %}
<div class="row">
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form) -}}
</div>
</div>
</div>
<br/>
{% endblock %}
That works perfectly in one case but now I have a FormFlow (CraueFormFlow) and one of my multi-steps form is :
class AddChildStep3 extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('childsFamily', CollectionType::class, array(
'entry_type' => RelationshipType::class,
'allow_add' => true
));
}
public function getBlockPrefix()
{
return 'AddChildStep3';
}
That renders a collection of this form :
/**
* {#inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('relRole', EntityType::class, array(
'class' => 'VSCrmBundle:RelRole'
))
//->add('sourceId', PersonChildType::class)
->add('destinationId', PersonRelationshipType::class);
}
/**
* {#inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'VS\CrmBundle\Entity\Relationship'
));
}
/**
* {#inheritdoc}
*/
public function getBlockPrefix()
{
return 'vs_crmbundle_relationship';
}
and the problem is that the form_row that I've defined before wors well for relRole of the last form but the destinationId property is showing this :
So the DestinationId label is inside the <div class="col-lg-4... and the widget is also inside a <div class=col-lg-4... and then inside the widget I have one more time label inside a <div class="col-lg-4 ...
I wanted to solve this by adding a new custom form_rom specially for this part so I've found the name of the block in profiler->forms->my form->vars->unique_block_prefix = _AddChildStep3_childsFamily and tried this :
{% block _AddChildStep3_childsFamily_entry_row %}
<div class="row">
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.relRole, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.relRole) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.relRole) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.firstName, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.firstName) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.firstName) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.lastName, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.lastName) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.lastName) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.bornOn, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.bornOn) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.bornOn) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.profession, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.profession) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.profession) -}}
</div>
</div>
<br/>
</div>
{% endblock %}
As it's written in the docs (http://symfony.com/doc/current/form/form_customization.html#how-to-customize-a-collection-prototype) but this doesn't work...
ps: for info my HTML in this case is
<div class="row">
<div id="familyMembersList" data-prototype="{{ form_widget(form.childsFamily.vars.prototype)|e('html_attr') }}">
</div>
</div>
EDIT: When I go to profiler/twig I don't see that Twig use my custom entry row ... Maybe the name of the custom block is wrong ? I've found the name of the block that I have to customize in an answer on stackoverflow.

Ok, After some head pain and several tries I've found that Symfony/Form/twig doesn't wants to customize the entry row. I've tried this :
{% block _AddChildStep3_childsFamily_entry_widget %}
<div class="row">
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.relRole, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.relRole) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.relRole) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.firstName, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.firstName) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.firstName) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.lastName, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.lastName) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.lastName) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.bornOn, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.bornOn) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.bornOn) -}}
</div>
</div>
<br/>
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_label(form.destinationId.profession, "", {'label_attr': {'class': 'pull-right'}}) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_widget(form.destinationId.profession) -}}
</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
{{- form_errors(form.destinationId.profession) -}}
</div>
</div>
<br/>
</div>
<br/>
{% endblock %}
And this works even is it's not perfect. Hope it can help :)

Related

don't get the right size on small screen

I'm using bootstrap4 and Stream UI Kit for the user interface in my application but i don't get the right size of column on the small screen !!
example !
it's supposed to be one per line when we browse on mobile !! with col-md-4 you can check the demo
<!-- Campaigns Grid -->
<section class="pt-11 pb-6 bg-light">
<div class="container">
<div class="d-flex justify-content-between align-items-center mb-5">
<h2 class="h3 text-center">{{ trans('user.offers') }}</h2>
{{ trans('user.all') }}
</div>
<div class="row">
#foreach($offers as $demand)
<div class="col-md-4 mb-5">
<div class="card h-100 border-0 shadow">
<a href="{{ url('/campaign/'.$demand->id) }}" class="d-block bg-gradient rounded-top">
<img class="card-img-top hover-fade-out" src="{{ url('upload/campaign/'. $demand->cover .'/') }}" alt="{{ $demand->title }}" height="244">
</a>
<div class="card-body">
<a href="{{ url('/campaign/'.$demand->id) }}">
<h3>{{ $demand->title }}</h3>
</a>
<p>
{!! str_limit(strip_tags($demand->content), 128) !!}
</p>
</div>
<div class="card-footer d-flex">
#foreach($demand->categories as $category)
#if(App::isLocale('ar')) <a href="{{ url('/category/'.$category->id) }} " class="badge badge-pill badge-secondary mr-1" >{{ $category->title_ar }} </a>
#elseif(App::isLocale('fr')) {{ $category->title }}
#else {{ $category->title_en }}
#endif
#endforeach
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!-- End Campaigns Grid -->
You can use, col-md-4 along with all classes for devices.
Use this in one in line
class=“col-6 col-md-4 col-sm-4 col-lg-4 col-xl-4”
These classes themselves give responsive on all devices.
col - set mobile
col-md - set medium devices
col-sm - small
col-lg - large
col-xl - extra large
They will manage automatically.

Bootstrap: align 'card's horizontally as a single row

i am rendering the 4 items in a row through a for loop , the problem is that in the first line it renders 4 items but the rest of the items that come in the loop are rendered in separate line.
code
<div class="card-group">
{% for item in wt %}
<div class="card my-3 text-white bg-dark mb-3" style="width: 18rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% if forloop.counter|divisibleby:4 %}
</div>
{% endif %}
{% endfor %}
here i am using bootstrap and django framework... i also used "row" class but it also doesnt work very well
It should automatically do 4 to a row without having to add extra code:
{% for item in wt %}
<div class="card my-3 text-white bg-dark mb-3" style="width: 18rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% endfor %}
If not, try using class "col-md-3" instead of "my-3".
Let me know if this does the trick.
it worked by changing size of the card and also adding forloop's counter... the main problem was the size of the card , it was not fitting in the container
<h2 class="my-4 text-white bg-dark">New Arrivals</h2>
<div class="row">
{% for item in wt %}
<div class="card text-white bg-dark mb-3" style="width: 10rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% if forloop.counter|divisibleby:4 %}
</div>
<div class="row">
{% endif %}
{% endfor %}
</div>

How to add button at the end of a loop with twig

UPDATE : I answer to my question with a solution who work. See below.
I created a loop that displays posts. Each two iteration a new row is created.
My loop iterate around this list of posts. The button is not considered in this array.
But my problem is that I would like to add a button in the last col.
In the options of my back office I give the possibility to show or not this button. So sometime I don't need to add a last col with this button.
Furthermore I need to add col-md-push-2 on each column on two because I use a Bootstrap grid (even on the column of the button when the button is active in the back office).
I wrote this code who work fine. But I don't know where to add my button.
<div class="group">
<div class="row">
{% for post in posts %}
<div class="col-xs-12 col-md-5 {% if loop.index is even %}col-md-push-2{% endif %}">
<div class="div-for-my-content">
Col content
</div>
{% if buttonIsActive %}
<div class="div-for-my-button">
Button
</div>
{% endif %}
</div>
{% if loop.index % 2 == 0 and not loop.last %}
</div>
</div>
<div class="group">
<div class="row">
{% endif %}
{% endfor %}
</div>
</div>
I don't know where can I add the code for my button. I know that I actually have my button in each row :-(
Example of html I try to generate.
<div class="group">
<div class="row">
<div class="col-xs-12 col-md-5 ">
<div class="div-for-my-content">
Col content
</div>
</div>
<div class="col-xs-12 col-md-5 col-md-push-2">
<div class="div-for-my-content">
Col content
</div>
</div>
</div>
</div>
<div class="group">
<div class="row">
<div class="col-xs-12 col-md-5 ">
<div class="div-for-my-content">
Col content
</div>
</div>
<div class="col-xs-12 col-md-5 col-md-push-2">
<div class="div-for-my-content">
Col content
</div>
</div>
</div>
</div>
<div class="group">
<div class="row">
<div class="col-xs-12 col-md-5">
<div class="div-for-my-button">
Button
</div>
</div>
</div>
</div>
I answer to my question with a variant who work and use batch.
{% for row in posts|batch(2) %}
<div class="group">
<div class="row">
{% for item in row %}
<div class="col-xs-12 col-md-5 {% if loop.index is even %}col-md-push-2{% endif %}">
<div class="div-for-my-content">
Col content
</div>
</div>
{% endfor %}
{% if btn_statut == true and loop.last and posts|length is not divisible by(2) %}
<div class="col-xs-12 col-md-5 col-md-push-2">
<div class="div-for-my-button">
Button
</div>
</div>
{% endif %}
</div>
</div>
{% if btn_statut == true and loop.last and posts|length is divisible by(2) %}
<div class="group">
<div class="row">
<div class="col-xs-12 col-md-5">
<div class="div-for-my-button">
Button
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
In order to place the button at the right spot, inside an open row, or open a new row you could check if the count of the items inside posts is even or not. Do note, u'd need to do the test twice, once for even and once for uneven
<div class="group">
<div class="row">
{% for post in posts %}
<div class="col-xs-12 col-md-5 {% if loop.index is even %}col-md-push-2{% endif %}">
<div class="div-for-my-content">
Col content
</div>
{% if loop.last and posts|length % 2 != 0 %}
<div class="div-for-my-button">
Button
</div>
{% endif %}
</div>
{% if loop.index % 2 == 0 and not loop.last %}
</div>
</div>
<div class="group">
<div class="row">
{% endif %}
{% endfor %}
</div>
{% if posts|length % 2 == 0 %}
<div class="row">
<div class="col-xs-12 col-md-5">
<div class="div-for-my-button">
Button
</div>
</div>
</div>
{% endif %}
</div>
demo

Unable to view multiple thumbnails in a row

I want to Get Thumbnails in a row. It's Getting a single column
I have Used Stock HTML Template The Template is working proper itself
I have corrected the row class but it's not coming as required
My Result
{% extends "base.html" %}
{% load static %}
{{% block content %}
<!-- ##### Listing Content Wrapper Area Start ##### -->
<section class="listings-content-wrapper section-padding-100">
<div class="container">
<div class="row">
<div class="col-12">
<div class="listings-top-meta d-flex justify-content-between mb-100">
<div class="view-area d-flex align-items-center">
<span>View as:</span>
<div class="grid_view ml-15"><i class="fa fa-th" aria-hidden="true"></i></div>
<div class="list_view ml-15"><i class="fa fa-th-list" aria-hidden="true"></i></div>
</div>
<div class="order-by-area d-flex align-items-center">
<span class="mr-15">Order by:</span>
<select>
<option selected>Default</option>
<option value="1">Newest</option>
<option value="2">Sales</option>
<option value="3">Ratings</option>
<option value="3">Popularity</option>
</select>
</div>
</div>
</div>
</div>
{% if listings %}
{% for listing in listings %}
<div class="row">
<!-- Single Featured Property -->
<div class="col-x-6 col-md-4">
<div class="single-featured-property mb-50">
<!-- Property Thumbnail -->
<div class="property-thumb">
<img src="{{listing.photo_main.url}}" alt="">
<div class="tag">
<span>For Sale</span>
</div>
<div class="list-price">
<p>₹{{listing.price}}</p>
</div>
</div>
<!-- Property Content -->
<div class="property-content">
<h5>{{listing.title}}</h5>
<p class="location"><img src="{% static 'img/icons/location.png'%}" alt="">{{listing.adderss}}</p>
<p>{{listing.description}}</p>
<div class="property-meta-data d-flex align-items-end justify-content-between">
<div class="new-tag">
<img src="{% static 'img/icons/new.png'%}" alt="">
</div>
<div class="bathroom">
<img src="{% static 'img/icons/bathtub.png'%}" alt="">
<span>{{listing.bathrooms}}</span>
</div>
<div class="garage">
<img src="{% static 'img/icons/garage.png'%}" alt="">
<span>{{listing.garage}}</span>
</div>
<div class="space">
<img src="{% static 'img/icons/space.png'%}" alt="">
<span>{{listing.sqft}} sq ft</span>
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
{% endif %}
<div class="row">
<div class="col-12">
<div class="south-pagination d-flex justify-content-end">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item"><a class="page-link active" href="#">01</a></li>
<li class="page-item"><a class="page-link" href="#">02</a></li>
<li class="page-item"><a class="page-link" href="#">03</a></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</section>
<!-- ##### Listing Content Wrapper Area End ##### -->
{% endblock %}}
I want to get 3 thumbnails in a row
css file is used from a stock template file.
Property listings should appear as in database.
Like This
You're generating a row for each listing. Ideally you'd want just the listings. So you can do:
{% if listings %}
{% for listing in listings %}
{% if forloop.counter0|divisibleby:3 %}<div class="row">{% endif %}
<!-- Single Featured Property -->
<div class="col-x-6 col-md-4">
<div class="single-featured-property mb-50">
<!-- Property Thumbnail -->
<div class="property-thumb">
<img src="{{listing.photo_main.url}}" alt="">
<div class="tag">
<span>For Sale</span>
</div>
<div class="list-price">
<p>₹{{listing.price}}</p>
</div>
</div>
<!-- Property Content -->
<div class="property-content">
<h5>{{listing.title}}</h5>
<p class="location"><img src="{% static 'img/icons/location.png'%}" alt="">{{listing.adderss}}</p>
<p>{{listing.description}}</p>
<div class="property-meta-data d-flex align-items-end justify-content-between">
<div class="new-tag">
<img src="{% static 'img/icons/new.png'%}" alt="">
</div>
<div class="bathroom">
<img src="{% static 'img/icons/bathtub.png'%}" alt="">
<span>{{listing.bathrooms}}</span>
</div>
<div class="garage">
<img src="{% static 'img/icons/garage.png'%}" alt="">
<span>{{listing.garage}}</span>
</div>
<div class="space">
<img src="{% static 'img/icons/space.png'%}" alt="">
<span>{{listing.sqft}} sq ft</span>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
Or if you want to generate a row for every three listings you'd do:
{% if listings %}
<div class="row">
{% for listing in listings %}
<!-- Single Featured Property -->
<div class="col-x-6 col-md-4">
<div class="single-featured-property mb-50">
<!-- Property Thumbnail -->
<div class="property-thumb">
<img src="{{listing.photo_main.url}}" alt="">
<div class="tag">
<span>For Sale</span>
</div>
<div class="list-price">
<p>₹{{listing.price}}</p>
</div>
</div>
<!-- Property Content -->
<div class="property-content">
<h5>{{listing.title}}</h5>
<p class="location"><img src="{% static 'img/icons/location.png'%}" alt="">{{listing.adderss}}</p>
<p>{{listing.description}}</p>
<div class="property-meta-data d-flex align-items-end justify-content-between">
<div class="new-tag">
<img src="{% static 'img/icons/new.png'%}" alt="">
</div>
<div class="bathroom">
<img src="{% static 'img/icons/bathtub.png'%}" alt="">
<span>{{listing.bathrooms}}</span>
</div>
<div class="garage">
<img src="{% static 'img/icons/garage.png'%}" alt="">
<span>{{listing.garage}}</span>
</div>
<div class="space">
<img src="{% static 'img/icons/space.png'%}" alt="">
<span>{{listing.sqft}} sq ft</span>
</div>
</div>
</div>
</div>
</div>
{% if forloop.counter0|divisibleby:3 %}</div>{% endif %}
{% endfor %}
{% endif %}

Include then block on a Twig template

None of the previous questions seem to have any information and about a day and a half of random Google searches turns up nothing.
What I am trying to do is this, I have a base.html.twig template and then a folder with several ui elements (slideshows, navigation menus, etc). The idea being I should be able to do this:
page.html.twig contains
{% extends 'OnMyLemonCommonBundle::base.html.twig' %}
{% block content %}
{% include 'OnMyLemonCommonBundle::features.html.twig' %}
{% block features %}
<h2>Featured Articles</h2>
<li>Article 1</li>
<li>Article 2</li>
{% endblock %}
{% endblock %}
features.html.twig contains
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="large-4 small-6 columns">
{% block features %}{% endblock %}
</div>
<div class="large-4 small-6 columns">
{% block blogs %}{% endblock %}
</div>
<div class="large-4 small-12 columns">
{% block pictures %}{% endblock %}
</div>
</div>
</div>
</div>
The problem is that this will render as follows:
// Content from top of base.html.twig
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="large-4 small-6 columns">
</div>
<div class="large-4 small-6 columns">
</div>
<div class="large-4 small-12 columns">
</div>
</div>
</div>
</div>
<h2>Featured Articles</h2>
<li>Article 1</li>
<li>Article 2</li>
// Content from bottom of base.html.twig
The question is how would I make this output the following:
// Content from top of base.html.twig
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="large-4 small-6 columns">
<h2>Featured Articles</h2>
<li>Article 1</li>
<li>Article 2</li>
</div>
<div class="large-4 small-6 columns">
</div>
<div class="large-4 small-12 columns">
</div>
</div>
</div>
</div>
// Content from bottom of base.html.twig
You could accomplish this by having an additional layer of inheritance in your twig files, e.g.:
features-base.html.twig contains:
{% extends 'OnMyLemonCommonBundle::base.html.twig' %}
{% block content %}
{% include 'OnMyLemonCommYonBundle::features.html.twig' %}
{% endblock %}
page.html.twig contains:
{% extends 'OnMyLemonCommonBundle::features-base.html.twig' %}
{% block features %}
<h2>Featured Articles</h2>
<li>Article 1</li>
<li>Article 2</li>
{% endblock %}
I don't think this is possible, however you can try to use the following
{% render'bundle:Controller:method' %}
Where you render it like this
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="large-4 small-6 columns">
{{ features }}
</div>
<div class="large-4 small-6 columns">
</div>
<div class="large-4 small-12 columns">
</div>
</div>
</div>
</div>
I hope this is a solution to your problem

Resources