An open API service indexing awesome lists of open source software.

https://github.com/lpogic/rebus

ruby stencil compiler
https://github.com/lpogic/rebus

ruby template-compiler

Last synced: 4 months ago
JSON representation

ruby stencil compiler

Awesome Lists containing this project

README

          

rebus - Ruby stencil compiler
===

Rebus template language compiler based on Ruby dynamic evaluation.
Minimalistic and customizable.

For example this document was rendered from [readme.md.rbs](https://github.com/lpogic/rebus/blob/main/doc/draft/readme.md.rbs) template.

Installation
---
```
gem install rebus
```

Basics
---

Rules are:
- input is interpreted line by line
- there are 3 different line types recognized by the following prefixes:
- `# ` - a comment line skipped during compilation
- `$ ` - a code line evaluated during compilation
- any other - a string line with possible interpolated code (see Ruby string interpolation rules)

#### Sample (stealed and translated from [ERB documentation](https://ruby-doc.org/stdlib-3.1.0/libdoc/erb/rdoc/ERB.html#class-ERB-label-Ruby+in+HTML)):

Template(Rebus - HTML):
```HTML

Ruby Toys -- #@name

#@name (#@code)


#@desc


    $ @features.each do |f|
  • #{f}

  • $ end


$ if @cost < 10
Only #@cost!!!
$ else
Call for a price, today!
$ end

```

Source code(Ruby):
```RUBY
require 'rebus'
require 'modeling' # to keep sample code concise

class Product
model :code, :name, :desc, :cost do
@features = [ ]
end

def add_feature( feature )
@features << feature
end
end

toy = Product.new( "TZ-1002",
"Rubysapien",
"Geek's Best Friend! Responds to Ruby commands...",
999.95 )
toy.add_feature("Listens for verbal commands in the Ruby language!")
toy.add_feature("Ignores Perl, Java, and all C variants.")
toy.add_feature("Karate-Chop Action!!!")
toy.add_feature("Matz signature on left leg.")
toy.add_feature("Gem studded eyes... Rubies, of course!")

puts Rebus.compile_file "a0.rbs", toy
```

Output(HTML):
```HTML

Ruby Toys -- Rubysapien

Rubysapien (TZ-1002)


Geek's Best Friend! Responds to Ruby commands...


  • Listens for verbal commands in the Ruby language!

  • Ignores Perl, Java, and all C variants.

  • Karate-Chop Action!!!

  • Matz signature on left leg.

  • Gem studded eyes... Rubies, of course!


Call for a price, today!

```

Usage
---
[Wiki](https://github.com/lpogic/rebus/blob/main/doc/wiki/README.md)

Authors
---
- Łukasz Pomietło (oficjalnyadreslukasza@gmail.com)