I'm building a Rest API with Symfony 3 and Fosresbundle and I use AngularJS to retrieve JSON datas inside twig templates.
For some reasons, I need to set angularJS directives and css classes just in the body tag but don't know how to perform that because in Twig, body tag is translated in block like this :
{% block body %}
...
{% endblock %}
Please how can I add angularJS directives and CSS classes in that Twig body block to get something similar to this HTML script :
<body class="myClass" ng-app="myApp" ng-controller="myController">
...
</body>
And my code looks a bit like :
Base.html.twig :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Mytitle{% endblock %}</title>
{% block stylesheets %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ asset('css/font-awesome/css/font-awesome.min.css') }}">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" type="text/css" href="{{ asset('css/mystuff.css') }}" />
<style>
iframe {
height: 100% !important;
width: 100% !important;
overflow: hidden;
}
</style>
</head>
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
{% block body %}
{% endblock %}
{% block javascripts %}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://code.angularjs.org/1.5.8/i18n/angular-locale_fr-fr.js"></script>
<script type="text/javascript" src="{{ asset('js/app.js') }}" ></script>
<script type="text/javascript" src="{{ asset('library/jquery/jquery-2.1.4.min.js') }}"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="{{ asset('js/mystuff.js') }}" ></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
{% endblock %}
</html>
index.html.twig
{% extends 'base.html.twig' %}
{% block body %}
<div class="container-fluid" ng-app="myApp" ng-controller="myController" ng-init="getContenurByID({{ idConteneur }})">
<div class="row rowLectureContenu">
<div class="col-sm-12 col-md-7 col-lg-7 no-float" style="padding: 0 !important; border: 1px solid lightgrey">
<iframe ng-src="{[{contenuURL}]}" style="border: none;"></iframe>
</div>
<div class="hidden-sm hidden-xs col-md-5 col-lg-5 no-float" style=" padding:0; border: 1px solid lightgrey">
Content...
</div>
</div>
</div>
{% endblock %}