Skip to content

Instantly share code, notes, and snippets.

@greenlaw110
Last active October 6, 2015 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenlaw110/3015037 to your computer and use it in GitHub Desktop.
Save greenlaw110/3015037 to your computer and use it in GitHub Desktop.
Define method in Rythm template
@extends(main)
@if (isMobile()) {
@layout.mobile()
} else {
@layout.desktop()
}
<!DOCTYPE html>
@import com.greenlaw110.utils.UserAgent
@// define a reusable function here, could be used by this template or sub template
@def boolean isMobile() {
@{UserAgent ua = getRenderArgs("userAgent");return ua.isMobile()}
}
<html>
<head>
</head>
...
@doLayout()
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment