New release Crinja 0.4.0 makes use of of Crystal annotations

This release comes with some refactorings of the public API to make it easier to use. Most prominently, annotation based autogenerator for exposing object properties to the Crinja runtime were added.

require "crinja"

class User
  include Crinja::Object::Auto

  @[Crinja::Attribute]
  def name : String
    "john paul"
  end
end

Crinja.new.from_string("{{ user.name }}").
  render({"user" => User.new}) # => "john paul"

More details on the release page.

Crinja v0.3.0 released

The new release brings support for Crystal 0.25.1 and also a few API improvements to simplify things. It also removes recursive aliases and uses Crinja::Value as a thin wrapper similar to JSON::Any in Crystal 0.25.0.

You need a runtime template engine? Check it out!

https://github.com/straight-shoota/crinja/releases/tag/v0.3.0

I'm already exploring how to use Crystal's new custom annotations feature to expose Crystal objects to the Crinja runtime in a safe and easy way.

Crinja - A Runtime Template Engine

Crinja is a template engine based on the famous Jinja2 template language with control structures, template inheritance and custom tags and filters. Most template engines for Crystal run at compile time, which needs to rebuild an application to change a template. Crinja evaluates templates at runtime, so you can use it for used-defined templates, dynamic configuration values, static-site generators and many other things (there are a few examples included). Rendering a template is as simple as:

tpl = Crinja::Template.new("Hello, {{ name | upper }}!")
tpl.render({"name" => "John"}) # => "Hello, JOHN!"

Usage API Documentation