Quantcast

How to test in a GSP if not in an environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to test in a GSP if not in an environment

Justin Stockton
I'm probably missing something easy here but I'm stumped. Is there a way to test with g:if whether or not the environment is NOT production? <g:if env="! production"> doesn't work even though looking at the g:if taglib code makes me think that it should since it's just using the expression in an if(). So far the only way I can get this to work is to do:

<g:if env="production"></g:if>
<g:else>
[code goes here]
</g:else>

Thanks for the help,

- Justin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to test in a GSP if not in an environment

Scott Burch
Yes.  I don't remember the exact syntax off the top of my head, but one
of the two below should work.

<%@ page import="grails.util.Environment" %>
<g:if test="${Environment.current == Environment.PRODUCTION}">

// ensure you import GrailsUtil
<g:if test="${GrailsUtil.environment == Environment.PRODUCTION}">

As a side note.  Please utilize google before asking a question here.
The above examples were pulled from a very simple google search.

"grails environment g:if"



On Fri, 2009-08-07 at 10:26 -0600, Justin Stockton wrote:

> I'm probably missing something easy here but I'm stumped. Is there a
> way to test with g:if whether or not the environment is NOT
> production? <g:if env="! production"> doesn't work even though looking
> at the
> g:if taglib code makes me think that it should since it's just using
> the expression in an if(). So far the only way I can get this to work
> is to do:
>
> <g:if env="production"></g:if>
> <g:else>
> [code goes here]
> </g:else>
>
> Thanks for the help,
>
> - Justin
--
SmartWeb Systems - "Websites that think, should be smart"
Groovy/Grails development
Phone (USA): 518-632-6679
Phone (CAN): 514-885-6457
http://www.smartwebsystems.biz



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to test in a GSP if not in an environment

Tebogo
In reply to this post by Justin Stockton
This should work: <g:if env='!${development}'> 
Loading...