Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is what I do in mustache.java:</p> <pre class="lang-java prettyprint-override"><code>import java.util.Collection; import java.util.Map; import java.util.Set; public class UrlHelper implements Map&lt;String, String&gt; { public static final UrlHelper instance = new UrlHelper(); private static final String NORMAL_PREFIX = "url"; private final String virtualHost; // configure virtualhost here private UrlHelper() { virtualHost = "/"; } public boolean containsKey(Object key) { return key.toString().indexOf(':') != -1; } public String get(Object key) { String k = key.toString(); String prefix = k.substring(0, k.indexOf(':')); String url = k.substring(k.indexOf(":") + 1); if (prefix.equals(NORMAL_PREFIX)) return virtualHost + url; return virtualHost + "static/" + prefix + "/" + url + "." + prefix; } // Default implementation for the other 'Map' methods } </code></pre> <p>When rendering I do this:</p> <pre><code>mustache.execute(writer,new Object[] { model, UrlHelper.instance }).flush(); </code></pre> <p>You can use like this(assume your app is hosted at /app):</p> <pre><code>{{js:lib/jquery}} {{! /app/static/js/lib/jquery.js }} {{css:site}} {{! /app/static/css/site.css }} {{url:users/edit/1}} {{! /app/users/edit/1 }} </code></pre> <p>It is also possible to have a single prefix for all static resources(eg: static), but you can't use dots to specify the file extension, so you must use some other character to represent dots and replace in your processing code.</p> <p>You can probably adapt this technique to your web framework/language. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload