Rythm template engine define custom method in Java code -


i know there possibility define method in templates this:

@def mymethod(string parameter){      before @parameter after  } 

and use it:

@mymethod("my object") 

this output: before object after can define mymethod in java code , use in multiple templates ?

you don't need define method in java code. instead in rythm template home directory create file named __global.rythm, , define method there, rythm template automatically pick method because __global.rythm @include rythm engine in every template automatically. below real global rythm file project:

@import com.abc.model.* @import org.rythmengine.spring.web.csrf @import org.rythmengine.rythmengine @import com.abc.appconfig @import com.abc.model.color.*; @args csrf csrf   @def string csrfparam() {   return "__csrf=" + ((null == csrf) ? "nocsrf" : csrf.value); }  @def rythmengine rythm() {   return __engine(); }  @def user me() {   return user.me(); }  @def boolean loggedin() {   return user.me() != null; }  @def string host() {   return com.abc.appconfig.host() } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -