\n\n...\n\n```\n\nAsset serving is handled by Vert.x using the [[io.vertx.ceylon.core.http::HttpServerResponse#sendFile]]\nmethod that streams the content from disk to the outgoing connection bypassing userspace altogether in\na very efficient manner.\n\n## Templating\n\nCayla provides an extensible template engine build on top of Ceylon language constructs.\n\n HTML {\n BODY {\n H1 { \"Hello World\" }\n }\n }\n\n### Elements\n\nThe engine provides a set of out of the box elements such as HTML, BODY, DIV, etc... Elements can have\nattributes and content.\n\n A { href=\"http://localhost:8080/home\"; \"Home\" }\n\nString can also be produced with `String()` arguments (function) that provides a _lazy_ evaluation of the \nvalue:\n\n A { href= ()=>url; ()=>name }\n\nThe `()=>url` and `()=>name` constructs are used to defer the evaluation until the template is rendered.\n\n### Aliases\n\nThe template engine defines two important alias\n- `shared alias Child => String|String()|Node`\n- `shared alias Attr => String|String()`\n\nThose aliases are used by the engine declarations and it is best to keep them in mind when using the \nengine.\n \n### Tags\n\nThe engine provides a set of useful tags for creating dynamic templates\n\n#### Each tag\n\nThe each tag provides iteration over Ceylon iterables, design for working with Ceylon comprehensions.\n\n UL {\n each({for (i in 0..3) LI { \"The item ``i`` } })\n }\n\n#### When tag\n\nThe when tag provides conditional dispatch:\n\n DIV {\n when(() => x).\n eval { to = 0; \"zero\" }.\n eval { to = 1; \"one\" }.\n otherwise { \"too large\" }.\n }\n\n### Usage patterns\n\nSince the engine is based on Ceylon syntax, there are a few useful constructs naturally possible for using\nthe engine in a web application.\n\n#### Parameterized template\n\n Template index(String title) =>\n HTML {\n HEAD {\n TITLE { title } \n }\n };\n\n class Controller1(shared String param) extends Controller() {\n Response handle() => ok {\n index(param);\n };\n }\n\n#### Encapsulate and reuse\n\nTemplate fragment can be encapsulated\n\n DIV controlGroup(Child* children) =>\n DIV { className = \"control-group\";\n DIV { className= \"controls\"; children = children; }\n };\n\nand can then be reused easily\n\n value form = FORM { className = \"form-signin\"; action = \"http://localhost:8080/\";\n controlGroup(INPUT { type = \"text\"; name = \"name\"; }),\n controlGroup(BUTTON { className = \"btn btn-default\"; type = \"submit\"; \"Say Hello\" })\n }\n\n#### Mix with controller handler URLs\n\nHandlers can be used for creating safe urls (i.e generated by Cayla), such syntax can be used with\nlazy evaluation:\n\n A { href= ()=>Product(\"cars\"); \"Cars\" }\n\n#### Extensible\n\nThe engine is extensible, you can easily extends the engine with your own elements and tags.","softwareVersion":"0.3.2","datePublished":"2021-02-13","keywords":["web","ceylon"],"potentialAction":{"@type":"UseAction","name":"Add dependency to Maven or Gradle project","target":{"@type":"EntryPoint","urlTemplate":"https://mvnrepository.com/artifact/io.cayla/web","actionPlatform":["http://schema.org/DesktopWebPlatform"]}},"isBasedOn":{"@type":"SoftwareSourceCode","name":"Java","url":"https://openjdk.org/"}}]
# The Cayla Web Framework Cayla makes easy creating web application with Ceylon. ## Creating a simple application in seconds ### Import the Cayla module module my.app "1.0.0" { import io.cayla.web "0.3.1"; } ### Write the controller import io.cayla.web { ... } object controller { route("/") shared class Index() extends Handler() { Response handle() => ok { "Hello World"; }; } } shared void run() { value ...

Latest Versions

3 versions โ†’
VersionVulnerabilitiesUsagesDate
0.3.x
0.3.2
1
Feb 13, 2021
0.3.1
1
Feb 13, 2021
0.3.0
0
Feb 13, 2021
3 versions โ†’