octopress-ink 1.0.0.alpha.19 → 1.0.0.alpha.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f2fb82a20098cdfe2f3e53ba1d8698b2c687afb
4
- data.tar.gz: 70ccb3b9d8223443f105e6457b000dbdb5e8efc9
3
+ metadata.gz: 6d06768e2605f32b222536b3b637371edeb7c8ee
4
+ data.tar.gz: 10ec8710720d37bfc0dc963849f8e05ef0e25d85
5
5
  SHA512:
6
- metadata.gz: 5d98ccf5704b0055c3acc922eda1bd69dc38387022cabe493bfefc553795af644747ed2cbac4c585e262f8431f94618b4ae99e01787dd1c896479dc8785c88c6
7
- data.tar.gz: b2c296c4fcce0c5f40928448b72423b48b29c0b50969d5b27e4e54054566e78b0ee2ce0b18a9f2794765058f42ed1b7cf64e497a781d739e23e164dddc5674e3
6
+ metadata.gz: 4c7fb93d8f87cad0e5cb196e34c02733baf38672d9de4e1862ebcd8e0326fdba1eb8bb5436309992b00a7b9880cf4d5548e7ffc9dc2dad16ef3bb5656eeb1d1e
7
+ data.tar.gz: 6fe264b8152f0f8a12e0295e1f111d66650d561eda2a55b7ff424aa7487ebfa548fc5b80fc6f9451b51b2581c6d51292b437d2128c45886e97557da7ffaa5bd3
@@ -0,0 +1,22 @@
1
+ module Octopress
2
+ module Helpers
3
+ module Conditional
4
+ SYNTAX = /(.+)(if|unless)\s*(.+)/
5
+
6
+ def self.parse(markup, context)
7
+ if markup =~ SYNTAX
8
+ case $2
9
+ when 'if'
10
+ tag = Liquid::If.new('if', $3, ["true","{% endif %}"])
11
+ when 'unless'
12
+ tag = Liquid::Unless.new('unless', $3, ["true","{% endunless %}"])
13
+ end
14
+ tag.render(context) != ''
15
+ else
16
+ true
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ module Octopress
2
+ module Helpers
3
+ module Path
4
+ FILE = /(\S+)(\s.+)/
5
+ def self.parse(markup, context)
6
+ if markup =~ FILE
7
+ (context[$1].nil? ? $1 : context[$1]) + $2
8
+ else
9
+ markup
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Helpers
3
+ autoload :Conditional, 'octopress-ink/helpers/conditional'
4
+ autoload :ContentFor, 'octopress-ink/helpers/content_for'
5
+ autoload :Path, 'octopress-ink/helpers/path'
6
+ end
7
+ end
@@ -5,10 +5,17 @@ module Octopress
5
5
 
6
6
  def initialize(tag_name, markup, tokens)
7
7
  super
8
- @block_name ||= Helpers::ContentFor.get_block_name(tag_name, markup)
8
+ @tag_name = tag_name
9
+ @markup = markup
9
10
  end
10
11
 
11
12
  def render(context)
13
+ if @markup =~ Helpers::Conditional::SYNTAX
14
+ return unless Helpers::Conditional.parse(@markup, context)
15
+ @markup = $1
16
+ end
17
+
18
+ @block_name ||= Helpers::ContentFor.get_block_name(@tag_name, @markup)
12
19
  Helpers::ContentFor.append_to_block(context, @block_name, super)
13
20
  ''
14
21
  end
@@ -9,6 +9,11 @@ module Octopress
9
9
  end
10
10
 
11
11
  def render(context)
12
+ if @markup =~ Helpers::Conditional::SYNTAX
13
+ return unless Helpers::Conditional.parse(@markup, context)
14
+ @markup = Helpers::Path.parse($1, context)
15
+ end
16
+
12
17
  include_tag = Jekyll::Tags::IncludeTag.new('include', @markup, [])
13
18
 
14
19
  # If markup references a plugin e.g. plugin-name:include-file.html
@@ -6,10 +6,18 @@ module Octopress
6
6
  HAS_YIELD = /(.*?)({=\s*yield\s*})(.*)/im
7
7
  def initialize(tag_name, markup, tokens)
8
8
  super
9
- @block_name = Helpers::ContentFor.get_block_name(tag_name, markup)
9
+ @markup = markup
10
+ @tag_name = tag_name
10
11
  end
11
12
 
12
13
  def render(context)
14
+ if @markup =~ Helpers::Conditional::SYNTAX
15
+ return unless Helpers::Conditional.parse(@markup, context)
16
+ @markup = $1
17
+ end
18
+
19
+ @block_name = Helpers::ContentFor.get_block_name(@tag_name, @markup)
20
+
13
21
  wrap = super.strip
14
22
  content = Helpers::ContentFor.render(context, @block_name).strip
15
23
 
@@ -9,6 +9,11 @@ module Octopress
9
9
  end
10
10
 
11
11
  def render(context)
12
+ if @markup =~ Helpers::Conditional::SYNTAX
13
+ return unless Helpers::Conditional.parse(@markup, context)
14
+ @markup = $1
15
+ end
16
+
12
17
  content = Helpers::ContentFor.render(context, @block_name)
13
18
  if @block_name == 'head'
14
19
  content.insert 0, "<meta name='generator' content='Octopress #{Octopress::Ink::VERSION}'>\n"
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Ink
3
- VERSION = "1.0.0.alpha.19"
3
+ VERSION = "1.0.0.alpha.20"
4
4
  end
5
5
  end
data/lib/octopress-ink.rb CHANGED
@@ -6,11 +6,11 @@ require 'octopress-ink/version'
6
6
  require 'octopress-ink/generators/plugin_assets'
7
7
  require 'octopress-ink/jekyll/hooks'
8
8
  require 'octopress-ink/version'
9
- require 'octopress-ink/helpers/content_for'
10
9
 
11
10
  module Octopress
12
11
  CUSTOM_DIR = "_custom"
13
12
 
13
+ autoload :Helpers, 'octopress-ink/helpers'
14
14
  autoload :Assets, 'octopress-ink/assets'
15
15
  autoload :StaticFile, 'octopress-ink/assets/static_file'
16
16
  autoload :StaticFileContent, 'octopress-ink/assets/static_file_content'
data/test/_config.yml CHANGED
@@ -3,3 +3,4 @@ markdown: redcarpet
3
3
  pygments: true
4
4
  source: source
5
5
  destination: site
6
+ include_test: foo.html
@@ -0,0 +1,6 @@
1
+ Testing Include var_test
2
+
3
+
4
+
5
+ Testing Include var_test
6
+
@@ -0,0 +1,6 @@
1
+ Testing Include var_test
2
+
3
+
4
+
5
+ Testing Include var_test
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+ {% include foo.html some_var="var_test" if site.name == 'Your New Jekyll Site' %}
4
+ {% include site.include_test some_var="var_test" if site.name != 'Your New Jekyll Site' %}
5
+ {% include site.include_test some_var="var_test" unless site.name == 'Your New Jekyll Site' %}
6
+ {% include site.include_test some_var="var_test" unless site.name == 'Your Stupid Website' %}
data/test/test.rb CHANGED
@@ -39,7 +39,7 @@ end
39
39
  build
40
40
 
41
41
  def test_tags(dir)
42
- tags = %w{content_for footer head include include_plugin include_theme include_theme_override scripts}
42
+ tags = %w{content_for footer head include include_plugin include_theme include_theme_override scripts include_if}
43
43
  tags.each { |file| test("tag_tests/#{file}.html", dir) }
44
44
  end
45
45
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-ink
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.19
4
+ version: 1.0.0.alpha.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -107,7 +107,10 @@ files:
107
107
  - lib/octopress-ink/assets/static_file_content.rb
108
108
  - lib/octopress-ink/assets/stylesheet.rb
109
109
  - lib/octopress-ink/generators/plugin_assets.rb
110
+ - lib/octopress-ink/helpers.rb
111
+ - lib/octopress-ink/helpers/conditional.rb
110
112
  - lib/octopress-ink/helpers/content_for.rb
113
+ - lib/octopress-ink/helpers/path.rb
111
114
  - lib/octopress-ink/jekyll/hooks.rb
112
115
  - lib/octopress-ink/plugin.rb
113
116
  - lib/octopress-ink/plugins.rb
@@ -150,6 +153,7 @@ files:
150
153
  - test/expected/tag_tests/footer.html
151
154
  - test/expected/tag_tests/head.html
152
155
  - test/expected/tag_tests/include.html
156
+ - test/expected/tag_tests/include_if.html
153
157
  - test/expected/tag_tests/include_plugin.html
154
158
  - test/expected/tag_tests/include_theme.html
155
159
  - test/expected/tag_tests/include_theme_override.html
@@ -174,6 +178,7 @@ files:
174
178
  - test/site/tag_tests/footer.html
175
179
  - test/site/tag_tests/head.html
176
180
  - test/site/tag_tests/include.html
181
+ - test/site/tag_tests/include_if.html
177
182
  - test/site/tag_tests/include_plugin.html
178
183
  - test/site/tag_tests/include_theme.html
179
184
  - test/site/tag_tests/include_theme_override.html
@@ -226,6 +231,7 @@ files:
226
231
  - test/source/tag_tests/footer.html
227
232
  - test/source/tag_tests/head.html
228
233
  - test/source/tag_tests/include.html
234
+ - test/source/tag_tests/include_if.html
229
235
  - test/source/tag_tests/include_plugin.html
230
236
  - test/source/tag_tests/include_theme.html
231
237
  - test/source/tag_tests/include_theme_override.html
@@ -284,6 +290,7 @@ test_files:
284
290
  - test/expected/tag_tests/footer.html
285
291
  - test/expected/tag_tests/head.html
286
292
  - test/expected/tag_tests/include.html
293
+ - test/expected/tag_tests/include_if.html
287
294
  - test/expected/tag_tests/include_plugin.html
288
295
  - test/expected/tag_tests/include_theme.html
289
296
  - test/expected/tag_tests/include_theme_override.html
@@ -308,6 +315,7 @@ test_files:
308
315
  - test/site/tag_tests/footer.html
309
316
  - test/site/tag_tests/head.html
310
317
  - test/site/tag_tests/include.html
318
+ - test/site/tag_tests/include_if.html
311
319
  - test/site/tag_tests/include_plugin.html
312
320
  - test/site/tag_tests/include_theme.html
313
321
  - test/site/tag_tests/include_theme_override.html
@@ -360,6 +368,7 @@ test_files:
360
368
  - test/source/tag_tests/footer.html
361
369
  - test/source/tag_tests/head.html
362
370
  - test/source/tag_tests/include.html
371
+ - test/source/tag_tests/include_if.html
363
372
  - test/source/tag_tests/include_plugin.html
364
373
  - test/source/tag_tests/include_theme.html
365
374
  - test/source/tag_tests/include_theme_override.html