2011-09-15 33 views
9

Làm cách nào để tạo HTML sau bằng mẫu đóng?Cách: Mẫu đóng để tạo HTML trong đó giá trị thuộc tính của phần tử chứa dấu ngoặc nhọn

<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.'}}"/> 

Mọi trợ giúp đều được đánh giá cao.

Dưới đây là những gì tôi đã thử cho đến bây giờ.

{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} 

Trả về lỗi 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}} 

Return Tag 'template' not at start of line [line 6, column 1]. lỗi.


{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} 

Returns 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]. lỗi.


{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} 

Returns template .testUser: Double left brace '{{' not allowed within a Soy tag delimited by double braces (consider inserting a space: '{ {') [line 7, column 165]. lỗi.


{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} 

Returns 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). lỗi.

Trả lời

10

Sử dụng Literal Command hoạt động như một sự quyến rũ. Nhờ có Jim.

{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

Dựa trên "Special Characters" section in the documentation, {lb}{rb} dường như là con đường để đi. Chúng sẽ thêm một dấu ngoặc nhọn trái hoặc dấu ngoặc nhọn, tương ứng, cho đầu ra của bạn dưới dạng văn bản thuần túy.

Các vấn đề liên quan