Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change provider api to do extension lookup on its own. Add benchmarks…
… for provider caching vs. compile_at_init caching
- Loading branch information
Showing
11 changed files
with
141 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "benchmark" | ||
require File.dirname(__FILE__) + '/../lib/templater' | ||
|
||
Templater.register_template_path File.dirname(__FILE__) + '/../examples/example2' | ||
|
||
TESTS = 100 | ||
|
||
Benchmark.bmbm do |b| | ||
b.report("no-cache") do | ||
Templater.caching = false | ||
t = Templater('treate/html/readme').new | ||
TESTS.times { t.run } | ||
end | ||
|
||
b.report("cache ") do | ||
Templater.caching = true | ||
t = Templater('treate/html/readme').new | ||
TESTS.times { t.run } | ||
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Templater | ||
module SectionProviders | ||
class MarkabyProvider < SectionProvider | ||
|
||
EXTENSIONS = ['.mab'] | ||
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
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,24 @@ | ||
module Templater | ||
module SectionProviders | ||
class TemplateProvider < SectionProvider | ||
EXTENSIONS = [''] | ||
|
||
def self.path_suitable?(full_path) File.directory?(full_path) end | ||
|
||
def initialize(full_path, owner) | ||
self.owner = owner | ||
owner.template_paths.each do |template_path| | ||
if full_path.index(template_path) == 0 | ||
path = full_path[template_path..-1] | ||
@template = Templater(owner.path, path).new(owner.options) | ||
end | ||
end | ||
raise ArgumentError, "no template at `#{full_path}'" unless @template | ||
end | ||
|
||
def render(locals = {}, &block) | ||
@template.run(locals) | ||
end | ||
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