2013-10-18 1 views
1

HTML의 작은 덩어리를 렌더링하는 grails 렌더링 태그가 있습니다. 때때로 HTMl은 일부 텍스트와 때로는 일부 텍스트와 링크를 표시해야합니다.g : grails의 렌더링 태그에 paremeter로 링크 전달

이 코드 덩어리는 잘 작동 :

   <g:render template='accountInfo' model="[ 
         'accountStatus':subscription.status, 
         'subscription':subscription.plan.name, 
         'msg':g.message (code: 'stripe.plan.info', args:'${[periodStatus, endDate]}')]"/> 

그러나 나는이 텍스트와 링크를 OUPUT하기 위해 같은 모델의 'MSG'변수에 대한 몇 가지 HTML에 통과 할 수 있어야합니다 :

   <g:render template='accountInfo' model="[ 
         'accountStatus':profile.profileState, 
         'subscription':'None selected yet', 
         'msg':<a href="${createLink(controller: 'charge', action: 'basicPlanList')}" title="Start your Subscription">Your profile is currently inactive, select a plan now to publish your profile.</a>]"/> 

코드가 작동하지 않습니다. 나는 태그 라이브러리에 대한 링크를 추가하는 시도했지만, 나는 'MSG'에 태그 라이브러리를 전달하는 방법을 알아낼 수 있습니다 :

   <g:render template='accountInfo' model="[ 
         'accountStatus':profile.profileState, 
         'subscription':'None selected yet', 
         'msg':<abc:showThatLink/>]"/> 

내가 텍스트를 전달 달성하는 최선의 방법에 대한 제안에 열려입니다 텍스트, 그리고 링크를위한 텍스트와 함께 grails createLink 클로저가 있습니다.

1 사용 시세 :

<g:render template='accountInfo' model='${ [msg: "<a href='www.someurl.com'>.. </a>"]}' /> 

2를 사용하여 다른 변수 :

<g:set var="myMsg> 
    <a href="www.someurl.com>...</a> 
</g:set>` 
<g:render template='accountInfo' model='[ 'msg': ${myMsg} ]'/> 

3 사용 <g:render />의 본문 내용 :

답변

3

는 여러 옵션이

<g:render template="accountInfo" model="[ .. ]"> 
    <a href="..">..</a> 
</g:render> 

본문 내용을 렌더링하려면 템플릿 (accountInfo) 안에 body() 메서드를 사용할 수 있습니다. 얼마 전에 좀 더 자세한 내용을 제공하는 small blog post about this을 썼습니다.

+0

# 2 작동하지만 msg를 실행하려면 종료 메시지를 제거해야했습니다. 'msg': myMsg – spock99