Lys template language in Ruby 😄
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
.gitignore
LICENSE
README.md
l.rb
l_spec.rb

README.md

lys.rb

Lys template language in Ruby 😄

Install

gem install lys

Examples

require 'lys'

puts(L.body {
  L.h1('What is love ?') +
  L.ul {
    L.li('Something in the air') +
    L.li('You can\'t catch it') +
    L.li(
      L.a('Keep trying', href: "https://en.wikipedia.org/wiki/Love")
    )
  }
})

A few more things:

L.p(L.raw('<script>alert("boo")</script>'))

# attributes '_' are replaced with '-'
L.button(data_id: 123) { 'click me' }
# => <button data-id="123">click me</button>

# shortcut to add classes and ids easily
L.button('#magic-button.very-big', onclick: 'add_it()') { 'Magic !' }

# one easy way to do loops and ifs
puts(
  L.h1('Welcome') +
  L.ul {
    'Try one of our recipes:' +
    recipes.map do |recipe|
      L.li {
        L.a(href: recipe.link) { recipe.name }
      }
    end.join(" ")
  )
)

Simple webserver with Sinatra

In app.rb:

require 'sinatra'
require_relative 'l'

get '/' do
  L.html {
    L.head {
      L.title 'User Gets'
    } +
    L.body {
      L.h1('User Gets') +
      L.p('Get services and goods')
    }
  }
end

Then ruby app.rb.