forked from cohitre/hanlon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
require 'hanlon/version' | ||
require 'hanlon/engine' | ||
require 'hanlon/loader' | ||
require 'hanlon/file' | ||
|
||
module Hanlon | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Hanlon | ||
class File | ||
def self.load file | ||
f = self.new "#{file}.hanlon" | ||
f.module | ||
end | ||
|
||
def initialize filename | ||
@template = ::File.read(filename) | ||
@engine = Hanlon::Engine.new @template | ||
end | ||
|
||
def module | ||
@module ||= @engine.module | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- hanlon :greet do |name| | ||
Hello #{name} | ||
|
||
- hanlon :greet_user do |user| | ||
= greet user[:name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'spec_helper' | ||
|
||
describe Hanlon::File do | ||
describe '#load' do | ||
it 'should load a file and return a module' do | ||
mod = Hanlon::File.load("#{File.dirname(__FILE__)}/../templates/greetings") | ||
mod.should be_a Module | ||
end | ||
end | ||
end |