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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:29:01+00:00 2026-05-29T10:29:01+00:00

We heavily use Smarty for all our front end templating. I have observed the

  • 0

We heavily use Smarty for all our front end templating. I have observed the following situation:

When my Smarty template is similar to as follows:

<li>
    {if $a == 'A'}
        {$var1}
    {else}
        {$var2}
    {/if}
    <br><span>SUBTEXT</span>
</li>

The final HTML which is delivered to the browser is:

<li>
                            65
                        <br><span>SUBTEXT</span>
        </li>

I would expect it to be more clean and something like:

<li>
    65<br><span>SUBTEXT</span>
</li>

or better:

<li>65<br><span>SUBTEXT</span></li>

Anyway I can do this with some configuration settings in Smarty 3? Any setting to format and clean the final HTML created?

Thanks

  • 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-29T10:29:02+00:00Added an answer on May 29, 2026 at 10:29 am

    You can load the output filter trimwhitespace. It removes HTML comments (except ConditionalComments) and reduces multiple whitespace to a single space everywhere but <script>, <pre>, <textarea>.

    You can easily make the filter remove space between <two> <tags> by altering line 62. change

    '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
    

    to

    '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1\2',
    

    and you’re done.

    Output filters run AFTER the template is rendered and BEFORE it’s sent to the browser. {strip} runs before the template is processed – it’s a compile-time thing. So the following

    {$some_var = "Hello\nworld"}
    {strip}
      -
      {$}
      -
    {/strip}
    

    will output

    -hello
    world-
    

    while the outputfilter would return

    - hello world -
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a small library for our in-company use, and have been heavily
We use backbone heavily for rendering our pages. All the data is passed as
I use Dreamweaver heavily for modifying Liferay templates (Velocity files), and then have to
I have a large Android application for my company and we heavily use the
I have a webpage which heavily makes use of jQuery. My goal is to
I have an MVC2 application and use ReSharper 6.1 - I've heavily customised the
I am going to use heavily some C-API in my C++ application, I have
I have a page in which I use javascript heavily, I use jquery, extjs,
We use ExtJS 3.x pretty heavily within our flagship application. Our application's admin area
I'm working on a scheme that will heavily use array fields in mongo documents,

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.