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 8586365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:17:34+00:00 2026-06-11T22:17:34+00:00

I created a filter in Twig that wraps some HTML around the output. E.g.

  • 0

I created a filter in Twig that wraps some HTML around the output. E.g.

{{ 'this is a "test"'|display }}

outputs

<div id="container">
  <div id="content">
    this is a "test"
  </div>
  <div id="toolbar">
    <a href="/edit.php">edit</a>
  </div>
</div>

The dilemma is, I would like that subsequent filters are applied only on the original content, and not on the entire html. E.g.

{{ 'this is a "test"'|display|upper|e }}

outputs

&LT;DIV ID=&QUOT;CONTAINER&QUOT;&GT;
  &LT;DIV ID=&QUOT;CONTENT&QUOT;&GT;
    THIS IS A &QUOT;TEST&QUOT;
  &LT;/DIV&GT;
  &LT;DIV ID=&QUOT;TOOLBAR&QUOT;&GT;
    &LT;A HREF=&QUOT;/EDIT.PHP&QUOT;&GT;EDIT&LT;/A&GT;
  &LT;/DIV&GT;
&LT;/DIV&GT;

but as you can imagine, I would prefer the output like this

<div id="container">
  <div id="content">
    THIS IS A &QUOT;TEST&QUOT;
  </div>
  <div id="toolbar">
    <a href="/edit.php">edit</a>
  </div>
</div>

Changing the filter order to

{{ 'this is a "test"'|upper|e|display }}

would work for the upper filter, but not for the escape filter, because it places itself always at the end of the filter queue. Also it should work with autoescape=true.

Reading the twig documentation, I can’t find a standard way to do what I want. Has someone maybe tried something similar? Or has someone an idea to work around the problem?

Thanks in advance!

  • 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-06-11T22:17:35+00:00Added an answer on June 11, 2026 at 10:17 pm

    Try:

    {{ 'this is a "test"'|upper|e|display }}
    

    Filter your content in first place and then wrap it.

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

Sidebar

Related Questions

I've created a search with a couple of comboboxes that allow users to filter
I've created a filtered view for a lookup via javascript that gets it's filter
I've created a filter to in my java webserver (appengine actually) that logs the
I have created a filter toolbar based on this example . I have an
I have created a javascript filter that is working but not all the time.
I've created an OnActionExecuted filter to populate some viewmodel attributes with data from db
I've created a table with a group filter so some values stay hidden. However,
I created a filterable BindingList from this source . It works great: list.Filter(Customer ==
In my layout.html.twig I have a navigation bar with some links. I want the
I created a filter that monitors the length of a request. long start =

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.