From 50c3fd95b310357e1eff8a3bea979b5fa612796c Mon Sep 17 00:00:00 2001 From: Peter Hilton Date: Sun, 6 Feb 2011 12:43:00 +0100 Subject: [PATCH] [#165] Docs: Variables and Scripts in routes --- documentation/manual/routes.textile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/documentation/manual/routes.textile b/documentation/manual/routes.textile index f8a5d5d18f..d5fec01b31 100644 --- a/documentation/manual/routes.textile +++ b/documentation/manual/routes.textile @@ -144,6 +144,18 @@ GET /pages/{id} Application.page The first route is equivalent to the second one when the page ID is ‘home’. However, since it has higher priority, this route will be used as the default for the call to Application.page with ID ‘home’. +h3. Variables and scripts + +You can also use the **${ … }** syntax for variables, and the **%{ … }** syntax for scripts in the **routes** file, as you can in templates. For example: + +bc. %{ context = play.configuration.getProperty('context', '') }% + +# Home page +GET ${context} Secure.login +GET ${context}/ Secure.login + +Another example is the CRUD module’s **routes** file, which uses the **crud.types** tag to loop over model types to generate controller route definitions for each type. + h2. Routes priority