10

如何获得以下使用闭包模板创建的 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).错误。

4

2 回答 2

13

使用文字命令就像一个魅力。感谢吉姆

{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}
于 2011-09-15T07:49:00.257 回答
1

基于文档中的“特殊字符”部分,似乎是要走的路。这些将分别以纯文本形式向您的输出添加左大括号或右大括号。{lb}{rb}

于 2017-08-08T01:44:49.480 回答