implement include tag
This commit is contained in:
parent
906ccbb873
commit
8b2aedc951
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -27,20 +27,23 @@ require 'jekyll/layout'
|
|||
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
|
||||
|
|
|
@ -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 @@ module Jekyll
|
|||
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('highlight', Jekyll::Highlight)
|
||||
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
|
|
@ -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)
|
|
@ -0,0 +1,3 @@
|
|||
--
|
||||
Tom Preston-Werner
|
||||
github.com/mojombo
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
layout: default
|
||||
title: Include
|
||||
---
|
||||
|
||||
{% include sig.textile %}
|
|
@ -83,4 +83,13 @@ class TestPost < Test::Unit::TestCase
|
|||
|
||||
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>—<br />\nTom Preston-Werner<br />\ngithub.com/mojombo</p> >>>", p.output
|
||||
end
|
||||
end
|
|
@ -19,7 +19,7 @@ class TestSite < Test::Unit::TestCase
|
|||
def test_read_posts
|
||||
@s.read_posts
|
||||
|
||||
assert_equal 2, @s.posts.size
|
||||
assert_equal 3, @s.posts.size
|
||||
end
|
||||
|
||||
def test_write_posts
|
||||
|
|
Loading…
Reference in New Issue