ohadpr
ohadpr

Reputation: 977

Why does Smarty replace things like '%>' with <?php echo '%>'; ?> and how to avoid this?

Im optimizing a Smarty template and things are looking good but the only thing left is that the resulting cached template is littered with things like <?php echo '%>'; ?> where it should just have '%>'.

It does the same for '?>' but that's understandable as it would confuse PHP, does '%>' have the same effect?

Upvotes: 0

Views: 170

Answers (2)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385405

As you point out, it does the same for the more traditional closing tag ?>.

Well, %> is a PHP closing tag too, albeit one disabled by default. You'd activate it with asp-tags:

Enables the use of ASP-like <% %> tags in addition to the usual tags. This includes the variable-> value printing shorthand of <%= $value %>. For more information, see Escaping from HTML.

Smarty's just being thorough. Unfortunately, it's not doing a very good job of it. Make sure that this is disabled and your problems should go away.

Upvotes: 1

edorian
edorian

Reputation: 38981

Take a look at the asp-tags ini setting:

asp_tags boolean

Enables the use of ASP-like <% %> tags in addition to the usual tags. This includes the variable-> value printing shorthand of <%= $value %>. For more information, see Escaping from HTML.

In newer php versions this is turned off by default so if smarty changes those i wouldn't be surprised. (If i understood you correctly)

Upvotes: 1

Related Questions