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
- Host: GitHub
- URL: https://github.com/lpogic/rebus
- Owner: lpogic
- Created: 2024-03-19T16:35:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-12T00:36:31.000Z (over 1 year ago)
- Last Synced: 2025-10-28T02:59:50.181Z (8 months ago)
- Topics: ruby, template-compiler
- Language: Ruby
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
- #{f}
$ @features.each do |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)