Как сделать: шаблон закрытия для генерации HTML, в котором значение атрибута элемента содержит фигурные скобки - PullRequest
10 голосов
/ 15 сентября 2011

Как получить следующий HTML, созданный с использованием шаблона закрытия?

<input name="fullName" class="large" type="text" data-validate="{required:true, minlength: 5, maxlength:100, messages:{required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'}}"/>

Любая помощь приветствуется.

Вот то, что я пробовал до сих пор.

{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{template .testUser autoescape="false"}
  {{msg desc="<input id=\"fullName\" name=\"fullName\" class=\"large\" type=\"text\" value=\"{$userToEdit.FullName}\" data-validate=\"{required:true, minlength: 5, maxlength:100, messages:{required:\'Please provide your Full Name.\', maxlength:\'This field can contain maximum 100 characters.\'} }\" />"}}
{/template}

Возвращает Malformed attributes in tag Ошибка.


{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{{template .testUser autoescape="false"}}
<input id="fullName" name="fullName" class="large" type="text" value="{{$userToEdit.FullName}}" data-validate="{required:true, minlength: 5, maxlength:100, messages:{required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'} }" />
{{/template}}

Возврат Tag 'template' not at start of line [line 6, column 1]. Ошибка.


{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{template .testUser autoescape="false"}
<input id="fullName" name="fullName" class="large" type="text" value="{$userToEdit.FullName}" data-validate="{required:true, minlength: 5, maxlength:100, messages:{required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'} }" />
{/template}

Возвращает template .testUser: Left brace '{' not allowed within a Soy tag delimited by single braces (consider using double braces to delimit the Soy tag) [line 7, column 164]. Ошибка.


{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{template .testUser autoescape="false"}
<input id="fullName" name="fullName" class="large" type="text" value="{$userToEdit.FullName}" data-validate="{{required:true, minlength: 5, maxlength:100, messages:{{required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'}} }}" />
{/template}

Возвращает template .testUser: Double left brace '{{' not allowed within a Soy tag delimited by double braces (consider inserting a space: '{ {') [line 7, column 165]. ошибка.


{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{template .testUser autoescape="false"}
<input id="fullName" name="fullName" class="large" type="text" value="{$userToEdit.FullName}" data-validate="{{required:true, minlength: 5, maxlength:100, messages:{ {required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'} } }}" />
{/template}

Возвращает template myApp.test.testUser: Not all code is in Soy V2 syntax (found tag {{print required:true, minlength: 5, maxlength:100, messages:{ {required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'} } }} not in Soy V2 syntax). ошибка.

Ответы [ 2 ]

13 голосов
/ 15 сентября 2011

Использование Буквальная команда работает как шарм. Благодаря Джиму .

{namespace myApp.test}
/**
 * Template for UI of Create User View 
 * @param userToEdit It is the object returned from GET on User Resource.
 */
{template .testUser autoescape="false"}
<input name="fullName" value="{$userToEdit.FullName}" class="large" type="text" {literal}data-validate="{required:true, minlength: 5, maxlength:100, messages:{required:'Please provide your Full Name.', maxlength:'This field can contain maximum 100 characters.'}}"{/literal}/>
{/template}
1 голос
/ 08 августа 2017

Основываясь на разделе «Специальные символы» в документации, , {lb} и {rb} кажутся подходящими. Они добавят левую или правую скобку, соответственно, к вашему выводу в виде простого текста.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...