سؤال

We're using Smarty to generate HTML from PHP. A number of plugins have been added to make life easier.

One of these plugins is a block plugin that interprets a custom language and generates HTML code. The custom language has simple statement, using linebreaks to separate the statements. Smarty's builtin {strip} plugin concatenates these statements onto a single line, making the language fail.

For instance, this is the input:

<div>
{table}
    column "Size" sortable editable number
    column "Color" sortable editable color
{/table}
</div>

If this is placed within a {strip}, the statements get concatenated and the language is no longer valid.

The simple solution is to place {/strip} and {strip} just outside the block plugin's open and close tags. However, this requires our template designers to remember this peculiarity (they don't).

Is there any way to disable {strip} for the content of a Smarty plugin?

هل كانت مفيدة؟

المحلول

I think the {literal} tag should escape stripping:

<div>
{table}{literal}
    column "Size" sortable editable number
    column "Color" sortable editable color
{/literal}{/table}
</div>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top