Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement include tag

  • Loading branch information...
commit 8b2aedc951bd0763b0a29f956053d59f5ab66a58 1 parent 906ccbb
@mojombo mojombo authored
View
4 History.txt
@@ -1,3 +1,7 @@
+==
+ * Major Features
+ * Include files in _includes with {% include x.textile %}
+
== 0.1.5 / 2008-12-12
* Major Features
* Code highlighting with Pygments if --pygments is specified
View
5 Manifest.txt
@@ -6,7 +6,6 @@ bin/jekyll
jekyll.gemspec
lib/jekyll.rb
lib/jekyll/albino.rb
-lib/jekyll/blocks.rb
lib/jekyll/converters/csv.rb
lib/jekyll/converters/mephisto.rb
lib/jekyll/convertible.rb
@@ -15,11 +14,15 @@ lib/jekyll/layout.rb
lib/jekyll/page.rb
lib/jekyll/post.rb
lib/jekyll/site.rb
+lib/jekyll/tags/highlight.rb
+lib/jekyll/tags/include.rb
test/helper.rb
+test/source/_includes/sig.textile
test/source/_layouts/default.html
test/source/_layouts/simple.html
test/source/_posts/2008-10-18-foo-bar.textile
test/source/_posts/2008-11-21-complex.textile
+test/source/_posts/2008-12-13-include.textile
test/source/css/screen.css
test/source/index.html
test/source/posts/2008-12-03-permalinked-post.textile
View
4 jekyll.gemspec
@@ -4,12 +4,12 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tom Preston-Werner"]
- s.date = %q{2008-12-12}
+ s.date = %q{2008-12-13}
s.default_executable = %q{jekyll}
s.email = ["tom@mojombo.com"]
s.executables = ["jekyll"]
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
- s.files = ["History.txt", "Manifest.txt", "README.textile", "Rakefile", "bin/jekyll", "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/blocks.rb", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/convertible.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "test/helper.rb", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/css/screen.css", "test/source/index.html", "test/source/posts/2008-12-03-permalinked-post.textile", "test/suite.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
+ s.files = ["History.txt", "Manifest.txt", "README.textile", "Rakefile", "bin/jekyll", "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/convertible.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "test/helper.rb", "test/source/_includes/sig.textile", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/_posts/2008-12-13-include.textile", "test/source/css/screen.css", "test/source/index.html", "test/source/posts/2008-12-03-permalinked-post.textile", "test/suite.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
s.has_rdoc = true
s.rdoc_options = ["--main", "README.txt"]
s.require_paths = ["lib"]
View
7 lib/jekyll.rb
@@ -27,20 +27,23 @@
require 'jekyll/page'
require 'jekyll/post'
require 'jekyll/filters'
-require 'jekyll/blocks'
+require 'jekyll/tags/highlight'
+require 'jekyll/tags/include'
require 'jekyll/albino'
module Jekyll
VERSION = '0.1.5'
class << self
- attr_accessor :lsi, :pygments
+ attr_accessor :source, :dest, :lsi, :pygments
end
Jekyll.lsi = false
Jekyll.pygments = false
def self.process(source, dest)
+ Jekyll.source = source
+ Jekyll.dest = dest
Jekyll::Site.new(source, dest).process
end
end
View
4 lib/jekyll/blocks.rb → lib/jekyll/tags/highlight.rb
@@ -1,6 +1,6 @@
module Jekyll
- class Highlight < Liquid::Block
+ class HighlightBlock < Liquid::Block
include Liquid::StandardFilters
def initialize(tag_name, lang, tokens)
@@ -34,4 +34,4 @@ def render_codehighlighter(context, code)
end
-Liquid::Template.register_tag('highlight', Jekyll::Highlight)
+Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
View
16 lib/jekyll/tags/include.rb
@@ -0,0 +1,16 @@
+module Jekyll
+
+ class IncludeTag < Liquid::Tag
+ def initialize(tag_name, file, tokens)
+ super
+ @file = file.strip
+ end
+
+ def render(context)
+ File.read(File.join(Jekyll.source, '_includes', @file))
+ end
+ end
+
+end
+
+Liquid::Template.register_tag('include', Jekyll::IncludeTag)
View
3  test/source/_includes/sig.textile
@@ -0,0 +1,3 @@
+--
+Tom Preston-Werner
+github.com/mojombo
View
6 test/source/_posts/2008-12-13-include.textile
@@ -0,0 +1,6 @@
+---
+layout: default
+title: Include
+---
+
+{% include sig.textile %}
View
9 test/test_post.rb
@@ -83,4 +83,13 @@ def test_data
assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: Fri Nov 21 00:00:00 -0800 2008<br />\nid: /2008/11/21/complex</p> >>>", p.output
end
+
+ def test_include
+ Jekyll.source = File.join(File.dirname(__FILE__), *%w[source])
+ p = Post.new(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-13-include.textile")
+ layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
+ p.add_layout(layouts, {"site" => {"posts" => []}})
+
+ assert_equal "<<< <p>&#8212;<br />\nTom Preston-Werner<br />\ngithub.com/mojombo</p> >>>", p.output
+ end
end
View
2  test/test_site.rb
@@ -19,7 +19,7 @@ def test_read_layouts
def test_read_posts
@s.read_posts
- assert_equal 2, @s.posts.size
+ assert_equal 3, @s.posts.size
end
def test_write_posts
Please sign in to comment.
Something went wrong with that request. Please try again.