@@ -38,7 +38,8 @@ public class GroovyPagesUriSupport implements GroovyPagesUriService, org.codehau
3838 private static final String BLANK = "" ;
3939 private static final String UNDERSCORE = "_" ;
4040 protected static final String EXTENSION = ".gsp" ;
41- protected static final String SUFFIX = ".gsp" ;
41+ protected static final String SUFFIX = ".gsp" ;
42+ public static final String RELATIVE_STRING = "../" ;
4243
4344 /**
4445 * Obtains a template URI for the given controller instance and template name
@@ -117,6 +118,9 @@ public String getTemplateURI(String controllerName, String templateName, boolean
117118 if (templateName .startsWith (SLASH_STR )) {
118119 return getAbsoluteTemplateURI (templateName , includeExtension );
119120 }
121+ else if (templateName .startsWith (RELATIVE_STRING )) {
122+ return getRelativeTemplateURIInternal (templateName , includeExtension );
123+ }
120124
121125 FastStringWriter buf = new FastStringWriter ();
122126 String pathToTemplate = BLANK ;
@@ -143,7 +147,6 @@ public String getTemplateURI(String controllerName, String templateName, boolean
143147 }
144148 }
145149
146-
147150 /**
148151 * Used to resolve template names that are not relative to a controller.
149152 *
@@ -173,6 +176,7 @@ public String getAbsoluteTemplateURI(String templateName, boolean includeExtensi
173176 return uri ;
174177 }
175178
179+
176180 /**
177181 * Obtains a view URI of the given controller name and view name
178182 * @param controllerName The name of the controller
@@ -230,9 +234,12 @@ public String getDeployedAbsoluteViewURI(String viewName) {
230234 }
231235
232236 private String getViewURIInternal (String viewPathPrefix , String viewName , FastStringWriter buf , boolean includeSuffix ) {
233- if (viewName != null && viewName .startsWith (SLASH_STR )) {
237+ if (viewName != null && ( viewName .startsWith (SLASH_STR ) )) {
234238 return getAbsoluteViewURIInternal (viewName , buf , includeSuffix );
235239 }
240+ else if (viewName .startsWith (RELATIVE_STRING )) {
241+ return getRelativeViewURIInternal (viewName , buf , includeSuffix );
242+ }
236243
237244 if (viewPathPrefix != null ) {
238245 buf .append (SLASH ).append (viewPathPrefix );
@@ -244,6 +251,15 @@ private String getViewURIInternal(String viewPathPrefix, String viewName, FastSt
244251 return includeSuffix ? buf .append (SUFFIX ).toString () : buf .toString ();
245252 }
246253
254+ private String getRelativeViewURIInternal (String viewName , FastStringWriter buf , boolean includeSuffix ) {
255+ String tmp = viewName .substring (RELATIVE_STRING .length () - 1 , viewName .length ());
256+ buf .append (tmp );
257+ if (includeSuffix ) {
258+ buf .append (SUFFIX );
259+ }
260+ return buf .toString ();
261+ }
262+
247263 private String getAbsoluteViewURIInternal (String viewName , FastStringWriter buf , boolean includeSuffix ) {
248264 String tmp = viewName .substring (1 ,viewName .length ());
249265 if (tmp .indexOf (SLASH ) > -1 ) {
@@ -257,7 +273,18 @@ private String getAbsoluteViewURIInternal(String viewName, FastStringWriter buf,
257273 buf .append (viewName .substring (1 ,viewName .length ()));
258274 }
259275 if (includeSuffix ) {
260- buf .append (SUFFIX ).toString ();
276+ buf .append (SUFFIX );
277+ }
278+ return buf .toString ();
279+ }
280+
281+ private String getRelativeTemplateURIInternal (String templateName , boolean includeSuffix ) {
282+ String tmp = templateName .substring (RELATIVE_STRING .length () , templateName .length ());
283+ FastStringWriter buf = new FastStringWriter ();
284+ buf .append ("/_" );
285+ buf .append (tmp );
286+ if (includeSuffix ) {
287+ buf .append (SUFFIX );
261288 }
262289 return buf .toString ();
263290 }
0 commit comments