Special characters when using <g:set> tag

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Special characters when using <g:set> tag

Brian Lawson
I'm trying to use the following to set a variable in my gsp file, but am getting an error:

Code:
<
g:set var="createReqInd" value="<span class='required-indicator'>*</span>"/>

Error:
Attribute value quote wasn't closed (var="createReqInd" value="<span class='required-indicator').


Can someone please tell me how to set the variable to this string?

Thanks

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Special characters when using <g:set> tag

micke_
I think you can do something like this
<g:set var="createReqInd" value="${'<span class=\'required-indicator\'>*</span>'}"/>




On 18 February 2015 at 14:44, Brian Lawson <[hidden email]> wrote:
I'm trying to use the following to set a variable in my gsp file, but am getting an error:

Code:
<
g:set var="createReqInd" value="<span class='required-indicator'>*</span>"/>

Error:
Attribute value quote wasn't closed (var="createReqInd" value="<span class='required-indicator').


Can someone please tell me how to set the variable to this string?

Thanks

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMPMOdaN20prqRsqj5UneRPUhNR0TenSUf6bQecCqnCz34%3DJVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Special characters when using <g:set> tag

micke_
Almost feel negligent for not making sure you were aware of how easy it is to create and custom tags in Grails, something which is perfect for when you want to re-use snippets of gsp/html.

class MyTagLib{
def requiredIndicator = {attrs ->
String indicator = attrs.indicator ?: '*'
out << "<span class='required-indicator'>${indicator}</span>"
}
}

This lives in grails-app/taglib folder under a package of your choosing.

And can then be easily used like this in your GSPs

<g:requiredIndicator />
or
<g:requiredIndicator indicator="req" />

There is lots more to custom tags (use of services, templates, body, etc.)

Hope this helps
Micke

On 18 February 2015 at 22:50, Mikael Andersson <[hidden email]> wrote:
I think you can do something like this
<g:set var="createReqInd" value="${'<span class=\'required-indicator\'>*</span>'}"/>




On 18 February 2015 at 14:44, Brian Lawson <[hidden email]> wrote:
I'm trying to use the following to set a variable in my gsp file, but am getting an error:

Code:
<
g:set var="createReqInd" value="<span class='required-indicator'>*</span>"/>

Error:
Attribute value quote wasn't closed (var="createReqInd" value="<span class='required-indicator').


Can someone please tell me how to set the variable to this string?

Thanks

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMPMOdZYQaR9AJyTPEVHWH5qoN%3DL9OUp%3DdJEkmgCxmq%3DBO%3DOcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Special characters when using <g:set> tag

Brian Lawson
Thanks Mikael,

I am very new to Groovy and Grails and I did not know about the custom tags.  Great to know!

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/cc98e07e-8842-4e85-bd40-26be2f48a06d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Special characters when using <g:set> tag

Brian Lawson
In reply to this post by micke_
I tried this just as a simple "get it working" bandaid, but I'm getting the same error.

On Wednesday, February 18, 2015 at 4:50:53 PM UTC-6, Mikael Andersson wrote:
I think you can do something like this
<g:set var="createReqInd" value="${'<span class=\'required-indicator\'>*</span>'}"/>




On 18 February 2015 at 14:44, Brian Lawson <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Mogq7xyp8DMJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">brianle...@...> wrote:
I'm trying to use the following to set a variable in my gsp file, but am getting an error:

Code:
<
g:set var="createReqInd" value="<span class='required-indicator'>*</span>"/>

Error:
Attribute value quote wasn't closed (var="createReqInd" value="<span class='required-indicator').


Can someone please tell me how to set the variable to this string?

Thanks

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Mogq7xyp8DMJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-dev-discuss+unsubscribe@....
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Mogq7xyp8DMJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-de...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/4b0a2f95-de5e-488e-8fe9-945104a7364c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Special characters when using <g:set> tag

micke_
Interesting, I tried that myself in an app I have which use Grails 2.2.4 and it worked.

On 19 February 2015 at 16:32, Brian Lawson <[hidden email]> wrote:
I tried this just as a simple "get it working" bandaid, but I'm getting the same error.

On Wednesday, February 18, 2015 at 4:50:53 PM UTC-6, Mikael Andersson wrote:
I think you can do something like this
<g:set var="createReqInd" value="${'<span class=\'required-indicator\'>*</span>'}"/>




On 18 February 2015 at 14:44, Brian Lawson <[hidden email]> wrote:
I'm trying to use the following to set a variable in my gsp file, but am getting an error:

Code:
<
g:set var="createReqInd" value="<span class='required-indicator'>*</span>"/>

Error:
Attribute value quote wasn't closed (var="createReqInd" value="<span class='required-indicator').


Can someone please tell me how to set the variable to this string?

Thanks

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+[hidden email].
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e0d9e0fe-e5d1-4586-94c2-e8ccea89d761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/4b0a2f95-de5e-488e-8fe9-945104a7364c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMPMOdavB%3Dyn3EqUhDO_XdUbZ%3DarUcvfmzD5yYRscpZWZOdMOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.