2011-09-15 1 views
9

Come posso ottenere il seguente codice HTML creato utilizzando il modello di chiusura?How To: Modello di chiusura per la generazione di HTML in cui il valore di attributo di un elemento contiene parentesi graffe

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

Qualsiasi aiuto è apprezzato.

Di seguito è quello che ho provato fino ad ora.

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

Restituisce Malformed attributes in tag errore.


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

ritorno Tag 'template' not at start of line [line 6, column 1]. errore.


{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]. errore.


{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]. errore.


{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). errore.

risposta

10

Utilizzare Literal Command ha funzionato come un fascino. Grazie a 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}