DEV Community

Wilson Tovar
Wilson Tovar

Posted on

Pope.cr: Micro templating engine for strings only. (Crystal version of Pope.js)

I have published the Crystal version of Pope: A fast, minimal and micro template engine for strings only, it plays well where you want to embed micro templates inside your module.

GitHub repo: https://github.com/krthr/pope.cr

Here is an example:

require "pope.cr"

data = {
  user: {
    id:       123,
    username: "krthr",
    admin:    true,
    config:   {
      email: "test@test.com",
    },
  },
}

Pope.pope(
  "The user {{user.username}} with id {{user.id}} is cool",
  data
) # "The user krthr with id 123 is cool"

Pope.prop(data, "user.id")           #  123
Pope.prop(data, "user.config.email") # test@test.com
Pope.prop(data, "nananana")          # nil
Enter fullscreen mode Exit fullscreen mode

I hope you enjoy!

Top comments (0)