Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:21:31+00:00 2026-05-28T04:21:31+00:00

My problem: I have 3 templates: main.html.twig (main layout file) layout.html.twig (a bundle specific

  • 0

My problem:

I have 3 templates:

  • main.html.twig (main layout file)
  • layout.html.twig (a bundle specific layout override which contains some bundle specific JS tags)
  • create.html.twig (a page specific template file which also contains some page specific JS tags)

I am defining a block called ‘javascript’ in my base layout (main.html.twig), then overriding it (but calling {{ parent() }} in layout.html.twig. This works fine, and the JS tags from the main template file are still included above those in the layout.html.twig template.

I then do the same in the create.html.twig file, overriding the block as follows:

{% block javascripts %}
    {{ parent() }}
    {% javascripts '@BundleName/Resources/public/js/application.album.uploader.js'
                   '@BundleName/Resources/public/js/jquery.uploadify.js'
                   '@BundleName/Resources/public/js/swfuploadify.js' filter='?yui_js' %}
         <script src='{{ asset_url }}' type='text/javascript'></script>
    {% endjavascripts %}
{% endblock %}

At this point, instead of just overriding the javascript block in the parent (layout.html.twig) and including all the scripts defined in the templates above it, it does the following:

  • Dumps the <script> tags in the middle of the output (which causes an error, because in my main.html.twig file I am only including the jQuery library at the end of the HTML markup
  • Then it also dumps the scripts out along with the rest of the others (as I would expect it to)

I am not sure what is causing the scripts to be dumped in the middle of the create.html.twig template, and I’m also confused as to why they’re being dumped to the screen twice (once in the middle of the create and then once at the bottom along with all the rest of my scripts from main.html.twig and layout.html.twig.

Has anyone got any ideas? Let me know if anything is unclear or if I can provide some more information.

EDIT:

File contents are below…

main.html.twig: https://gist.github.com/7f29353eaca0947528ce

layout.html.twig: https://gist.github.com/734947e9118b7765715e

create.html.twig: https://gist.github.com/c60c8d5c61e00ff86912

EDIT 2:

I’ve been having another look at the issue this morning and it looks as though its doing the same thing for stylesheets. I tried to define a new block called pagescripts in my layout.html.twig and then use the block in my create.html.twig but this had the same outcome, it just seems to dump the scripts and stylesheets wherever I use the

{% block pagescripts %} 
   (scripts here) 
{% endblock}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:21:31+00:00Added an answer on May 28, 2026 at 4:21 am

    I found the issue. In create.html.twig I was defining my {% block javascripts %} content inside inside my {% block content %}, so I assume Twig was rendering the output of the javascripts block inside the content block.

    Moving the {% block javascripts %} content outside of the {% block content %} block fixed the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem: I have a class which contains a template method execute which calls
I have some weird problem with templates. When trying to pass a parameterised iterator
I have problem with proper charset encoding part of HTML view. XSL file in
I have the following problem using template instantiation [*]. file foo.h class Foo {
Problem: I have an address field from an Access database which has been converted
I have been writing several class templates that contain nested iterator classes, for which
i have problem with django's named urls which is included with include keyword. In
I have a some html being generated by JQuery on a Share Point page.
I have a problem with class member function templates. It seems that gcc is
I have a problem with a template and pointers ( I think ). Below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.