Jon Diamond
Jon Diamond

Reputation: 210

Adding Slots to PHP Engine Template in Symfony 3

I'm having trouble adding slots...

I have the following in my base template:

 <?php $view['slots']->output('javascript', '') ?>

And in another template that extends that template I have:

<?php $view['slots']->start('javascript') ?>
<script type="text/babel" src="/src/react-nominate-request.js"></script>
<?php $view['slots']->stop() ?>

That script tag never appears. I've read through the docs and don't see what I am missing any help would be greatly appreciated.

Here is how I am extending my templates: I have a base template with doctype head, body and scripts used by entire app

I have a layout with the html structure for my app (header, footer, and margins) that extends the base template.

<?php $view->extend('::base.html.php') ?>

Each of the three pages in my application has page specific html (basically divs with IDs the react components reference) that extends the layout template //page template

<?php $view->extend(':interface:layout.html.php') ?>

Upvotes: 0

Views: 580

Answers (1)

Jon Diamond
Jon Diamond

Reputation: 210

I had the bright idea of changing the name of my slot to _scripts and that made it start working as expected....

Inside my base template:

<?php $view['slots']->output('_scripts') ?>

Upvotes: 0

Related Questions