DEV Community

Wilson Tovar
Wilson Tovar

Posted on

3

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)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay