digitalmars.D.announce - Temple v0.7.0: New API, Fewer Allocations
- Dylan Knutson (35/35) Nov 22 2014 Hey all,
- Dylan Knutson (8/8) Nov 25 2014 Also, because long compile times due to template compilation are
- Misu (3/3) Nov 29 2014 Im playing with vibed + temple, it's a very good work. I prefer
Hey all, I'd like to announce the release of Temple 0.7.0, a compile time templating engine for D. It's been a while since the last major release, and 0.7.0 brings a lot of changes and enhancements. Temple is a library for embedding arbitrary D code in text templates, similar to Vibe.d's Diet, or JS's Jade, but agnostic about the format of the text that it should output (much more similar to Ruby's ERB). An example, dynamically rendering text with embedded D code: --- auto hello = compile_temple!("Hello, <%= var.name %>"); auto ctx = new TempleContext; ctx.name = "Walter"; writeln(hello.toString(ctx)); // Writes "Hello, Walter" to stdout hello.render(stdout, ctx); // also writes "Hello, Walter" to stdout --- Templates can be arbitrarily nested, and the library includes a feature for 'yield'ing partial templates into a larger layout template. The "Filter" feature can dynamically transform template text as it's written to the output buffer, and can be used to build concepts like Safe Strings and automatic HTML escaping filters. I encourage you to look at some of the examples in the (fairly extensive) README. Here's the GitHub repo: https://github.com/dymk/temple For previous users of Temple, I'm sorry that the API has broken backwards compatibility. If you'd like to keep the old API, please keep tracking the 0.6.x versions. However, upgrading to 0.7.x should be a straightforward task of changing some 'alias'es to 'auto', and 'Temple{etc}' to 'compile_temple_{etc}'. More information on upgrading is available on the release page, here: https://github.com/dymk/temple/releases/tag/v0.7.0 Thank you! -- Dylan
Nov 22 2014
Also, because long compile times due to template compilation are a pain for both Vibe's Diet and Temple, I've put together a repo demonstrating how to do separate compilation with Temple templates: https://github.com/dymk/temple-separate-compilation The idea is to put views in separate Dub submodules, so if the views don't change, the submodule isn't recompiled with the rest of the application.
Nov 25 2014
Im playing with vibed + temple, it's a very good work. I prefer html over jade for my views. Thank you.
Nov 29 2014