darthapo-stratus 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/Changelog +11 -0
  2. data/Manifest +43 -17
  3. data/Rakefile +2 -2
  4. data/Readme.markdown +2 -3
  5. data/examples/dev-blog/StratusSite +26 -0
  6. data/examples/dev-blog/config/content.yaml +23 -0
  7. data/examples/dev-blog/config/defaults/article.html +10 -0
  8. data/examples/dev-blog/config/defaults/content.html +7 -0
  9. data/examples/dev-blog/config/defaults/page.html +10 -0
  10. data/examples/dev-blog/config/defaults/post.html +10 -0
  11. data/examples/dev-blog/config/site.yaml +21 -0
  12. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/awake_from_nib.rb +8 -0
  13. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/ib_action.rb +14 -0
  14. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/index.html +58 -0
  15. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/new_frame.rb +10 -0
  16. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/outlets.rb +2 -0
  17. data/examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/view_for_tag.rb +6 -0
  18. data/examples/dev-blog/content/articles/im-the-title/index.html +10 -0
  19. data/examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/html_test.html +5 -0
  20. data/examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/index.html +35 -0
  21. data/examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/liquid_example.js +14 -0
  22. data/examples/dev-blog/content/pages/about/index.html +7 -0
  23. data/examples/dev-blog/content/pages/home/index.html +34 -0
  24. data/examples/dev-blog/content/pages/projects/index.html +6 -0
  25. data/{test/fixtures/site/www/posts/new-blog → examples/dev-blog/content/posts/001_new-blog}/dom.js +0 -0
  26. data/examples/dev-blog/content/posts/001_new-blog/index.html +24 -0
  27. data/{test/fixtures/site/www/posts/new-blog → examples/dev-blog/content/posts/001_new-blog}/old.html +0 -0
  28. data/examples/dev-blog/content/posts/002_fun-for-the-whole-family/index.html +12 -0
  29. data/{test/fixtures/site/www/posts/fun-for-the-whole-family → examples/dev-blog/content/posts/002_fun-for-the-whole-family}/snippet_one.rb +0 -0
  30. data/examples/dev-blog/content/posts/003_life-is-quite-fun-really/index.html +12 -0
  31. data/{test/fixtures/site/www/theme → examples/dev-blog/themes/default}/scripts/code_highlighter.js +0 -0
  32. data/{test/fixtures/site/www/theme → examples/dev-blog/themes/default}/scripts/code_syntax.js +15 -6
  33. data/examples/dev-blog/themes/default/styles/code_syntax.css +95 -0
  34. data/{test/fixtures/site/www/theme → examples/dev-blog/themes/default}/styles/main.css +20 -7
  35. data/examples/dev-blog/themes/default/templates/articles/content.html +7 -0
  36. data/examples/dev-blog/themes/default/templates/articles/feed.xml +25 -0
  37. data/examples/dev-blog/themes/default/templates/articles/list.html +8 -0
  38. data/examples/dev-blog/themes/default/templates/layouts/main.html +40 -0
  39. data/examples/dev-blog/themes/default/templates/pages/content.html +7 -0
  40. data/examples/dev-blog/themes/default/templates/pages/feed.xml +25 -0
  41. data/examples/dev-blog/themes/default/templates/pages/list.html +11 -0
  42. data/examples/dev-blog/themes/default/templates/posts/content.html +19 -0
  43. data/examples/dev-blog/themes/default/templates/posts/feed.xml +25 -0
  44. data/examples/dev-blog/themes/default/templates/posts/list.html +10 -0
  45. data/lib/stratus.rb +5 -4
  46. data/lib/stratus/cli.rb +5 -0
  47. data/lib/stratus/filters.rb +13 -18
  48. data/lib/stratus/generator/builder.rb +25 -65
  49. data/lib/stratus/generator/context.rb +12 -6
  50. data/lib/stratus/generator/renderer.rb +58 -38
  51. data/lib/stratus/generator/scanner.rb +16 -10
  52. data/lib/stratus/logging.rb +25 -0
  53. data/lib/stratus/resources.rb +2 -3
  54. data/lib/stratus/resources/base.rb +10 -10
  55. data/lib/stratus/resources/template.rb +2 -0
  56. data/lib/stratus/settings.rb +29 -1
  57. data/lib/stratus/tags.rb +2 -1
  58. data/lib/stratus/tags/markdown.rb +6 -0
  59. data/lib/stratus/tags/sourcecode.rb +36 -0
  60. data/lib/stratus/tasks/app/boilerplate/config/defaults/post.default.html +2 -2
  61. data/lib/stratus/tasks/app/boilerplate/config/site.yaml +12 -1
  62. data/lib/stratus/tasks/site/new.rake +26 -2
  63. data/lib/stratus/version.rb +5 -0
  64. data/stratus.gemspec +3 -3
  65. data/test/fixtures/site/config/site.yaml +12 -1
  66. metadata +45 -19
  67. data/test/fixtures/site/www/index.html +0 -82
  68. data/test/fixtures/site/www/pages/about/index.html +0 -43
  69. data/test/fixtures/site/www/pages/home/index.html +0 -82
  70. data/test/fixtures/site/www/pages/index.html +0 -52
  71. data/test/fixtures/site/www/pages/projects/index.html +0 -43
  72. data/test/fixtures/site/www/posts/fun-for-the-whole-family/index.html +0 -66
  73. data/test/fixtures/site/www/posts/index.html +0 -63
  74. data/test/fixtures/site/www/posts/life-is-quite-fun-really/index.html +0 -58
  75. data/test/fixtures/site/www/posts/new-blog/index.html +0 -192
  76. data/test/fixtures/site/www/theme/styles/code_syntax.css +0 -68
  77. data/test/fixtures/site/www/themes/default/styles/main.css +0 -62
data/Changelog CHANGED
@@ -1,3 +1,14 @@
1
+ 2008-12-18 21:40:18 -0600
2
+ Updated manifest and gemspec
3
+
4
+ 2008-12-18 21:39:25 -0600
5
+ Mostly functional now...
6
+ * Added support for new:site
7
+ * Added textile and markdown liquid tags
8
+
9
+ 2008-12-18 05:57:16 -0600
10
+ First pass on builder
11
+
1
12
  2008-12-11 18:37:01 -0600
2
13
  Initial import of stratus
3
14
 
data/Manifest CHANGED
@@ -3,6 +3,46 @@ Manifest
3
3
  Rakefile
4
4
  Readme.markdown
5
5
  bin/stratus
6
+ examples/dev-blog/StratusSite
7
+ examples/dev-blog/config/content.yaml
8
+ examples/dev-blog/config/defaults/article.html
9
+ examples/dev-blog/config/defaults/content.html
10
+ examples/dev-blog/config/defaults/page.html
11
+ examples/dev-blog/config/defaults/post.html
12
+ examples/dev-blog/config/site.yaml
13
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/awake_from_nib.rb
14
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/ib_action.rb
15
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/index.html
16
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/new_frame.rb
17
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/outlets.rb
18
+ examples/dev-blog/content/articles/animating-nsviews-in-rubycocoa/view_for_tag.rb
19
+ examples/dev-blog/content/articles/im-the-title/index.html
20
+ examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/html_test.html
21
+ examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/index.html
22
+ examples/dev-blog/content/articles/liquid-js-a-non-evaling-template-engine-in-javascript/liquid_example.js
23
+ examples/dev-blog/content/pages/about/index.html
24
+ examples/dev-blog/content/pages/home/index.html
25
+ examples/dev-blog/content/pages/projects/index.html
26
+ examples/dev-blog/content/posts/001_new-blog/dom.js
27
+ examples/dev-blog/content/posts/001_new-blog/index.html
28
+ examples/dev-blog/content/posts/001_new-blog/old.html
29
+ examples/dev-blog/content/posts/002_fun-for-the-whole-family/index.html
30
+ examples/dev-blog/content/posts/002_fun-for-the-whole-family/snippet_one.rb
31
+ examples/dev-blog/content/posts/003_life-is-quite-fun-really/index.html
32
+ examples/dev-blog/themes/default/scripts/code_highlighter.js
33
+ examples/dev-blog/themes/default/scripts/code_syntax.js
34
+ examples/dev-blog/themes/default/styles/code_syntax.css
35
+ examples/dev-blog/themes/default/styles/main.css
36
+ examples/dev-blog/themes/default/templates/articles/content.html
37
+ examples/dev-blog/themes/default/templates/articles/feed.xml
38
+ examples/dev-blog/themes/default/templates/articles/list.html
39
+ examples/dev-blog/themes/default/templates/layouts/main.html
40
+ examples/dev-blog/themes/default/templates/pages/content.html
41
+ examples/dev-blog/themes/default/templates/pages/feed.xml
42
+ examples/dev-blog/themes/default/templates/pages/list.html
43
+ examples/dev-blog/themes/default/templates/posts/content.html
44
+ examples/dev-blog/themes/default/templates/posts/feed.xml
45
+ examples/dev-blog/themes/default/templates/posts/list.html
6
46
  lib/stratus.rb
7
47
  lib/stratus/cli.rb
8
48
  lib/stratus/filters.rb
@@ -11,6 +51,7 @@ lib/stratus/generator/builder.rb
11
51
  lib/stratus/generator/context.rb
12
52
  lib/stratus/generator/renderer.rb
13
53
  lib/stratus/generator/scanner.rb
54
+ lib/stratus/logging.rb
14
55
  lib/stratus/resources.rb
15
56
  lib/stratus/resources/attachment.rb
16
57
  lib/stratus/resources/base.rb
@@ -21,6 +62,7 @@ lib/stratus/resources/template.rb
21
62
  lib/stratus/settings.rb
22
63
  lib/stratus/tags.rb
23
64
  lib/stratus/tags/markdown.rb
65
+ lib/stratus/tags/sourcecode.rb
24
66
  lib/stratus/tags/textile.rb
25
67
  lib/stratus/tasks/app/boilerplate/StratusSite
26
68
  lib/stratus/tasks/app/boilerplate/config/defaults/page.default.html
@@ -38,6 +80,7 @@ lib/stratus/tasks/shared/system.rake
38
80
  lib/stratus/tasks/site/new.rake
39
81
  lib/stratus/tasks/site/site.rake
40
82
  lib/stratus/tasks/site/theme.rake
83
+ lib/stratus/version.rb
41
84
  stratus.gemspec
42
85
  test/fixtures/site/StratusSite
43
86
  test/fixtures/site/config/defaults/article.default.html
@@ -67,21 +110,4 @@ test/fixtures/site/themes/default/templates/objects/page.html
67
110
  test/fixtures/site/themes/default/templates/objects/page.index.html
68
111
  test/fixtures/site/themes/default/templates/objects/post.html
69
112
  test/fixtures/site/themes/default/templates/objects/post.index.html
70
- test/fixtures/site/www/index.html
71
- test/fixtures/site/www/pages/about/index.html
72
- test/fixtures/site/www/pages/home/index.html
73
- test/fixtures/site/www/pages/index.html
74
- test/fixtures/site/www/pages/projects/index.html
75
- test/fixtures/site/www/posts/fun-for-the-whole-family/index.html
76
- test/fixtures/site/www/posts/fun-for-the-whole-family/snippet_one.rb
77
- test/fixtures/site/www/posts/index.html
78
- test/fixtures/site/www/posts/life-is-quite-fun-really/index.html
79
- test/fixtures/site/www/posts/new-blog/dom.js
80
- test/fixtures/site/www/posts/new-blog/index.html
81
- test/fixtures/site/www/posts/new-blog/old.html
82
- test/fixtures/site/www/theme/scripts/code_highlighter.js
83
- test/fixtures/site/www/theme/scripts/code_syntax.js
84
- test/fixtures/site/www/theme/styles/code_syntax.css
85
- test/fixtures/site/www/theme/styles/main.css
86
- test/fixtures/site/www/themes/default/styles/main.css
87
113
  test/test_helper.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ $: << 'lib'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
4
  require 'rake/gempackagetask'
5
- require 'stratus'
5
+ require 'stratus/version'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
@@ -43,7 +43,7 @@ end
43
43
 
44
44
  desc 'Clean up'
45
45
  task :clean => :clobber_package do
46
- %w(diff diff email ri *.gem **/*~).each do |pattern|
46
+ %w(diff diff email ri *.gem **/*~ .DS_Store).each do |pattern|
47
47
  files = Dir[pattern]
48
48
  rm_rf files unless files.empty?
49
49
  end
data/Readme.markdown CHANGED
@@ -6,10 +6,9 @@ And yes, I know, I'm on a weird cloud kick.
6
6
 
7
7
  # Todo
8
8
 
9
-
9
+ * Add setting for including index or date (YYYY-MM-DD) in output slug
10
10
  * Read default content templates from config/defaults/
11
- * RSS/Atom feed generation
12
11
  * Incremental rendering
13
12
  * Publishing (S/FTP)
14
13
  * Tagging support (limited)
15
- * Category support (limited)
14
+ * Category support (limited)
@@ -0,0 +1,26 @@
1
+ # I'm a rake file, so you can put Rake tasks in here, if you like...
2
+
3
+
4
+ namespace :new do
5
+
6
+ desc "Creates a new page"
7
+ task :page=>'system:setup' do
8
+ if Stratus.args.length == 0
9
+ puts " You must specify a page title"
10
+ exit(1)
11
+ end
12
+ Stratus.args = ['page', Stratus.args[0]]
13
+ Rake::Task['new:content'].execute
14
+ end
15
+
16
+ desc "Creates a new blog post"
17
+ task :post=>'system:setup' do
18
+ if Stratus.args.length == 0
19
+ puts " You must specify a post title"
20
+ exit(1)
21
+ end
22
+ Stratus.args = ['post', Stratus.args[0]]
23
+ Rake::Task['new:content'].execute
24
+ end
25
+
26
+ end
@@ -0,0 +1,23 @@
1
+ default:
2
+ local_slug: 'index' # index | date | none
3
+ slug_format: '###'
4
+ sort: 'index'
5
+ reverse: false
6
+ feed: true
7
+
8
+ # Override per content type
9
+
10
+ articles:
11
+ sort: 'title'
12
+ local_slug: 'none'
13
+
14
+ pages:
15
+ sort: 'title'
16
+ local_slug: 'none'
17
+
18
+ posts:
19
+ local_slug: 'index'
20
+ remote_slug: 'date'
21
+ slug_format: '%Y-%m-%d'
22
+ sort: 'publish_date'
23
+ reverse: true
@@ -0,0 +1,10 @@
1
+ <head>
2
+ <title>{{ title }}</title>
3
+ <meta name="publish-date" content="{{ date | date:'%Y-%m-%d %H:%M' }}"/>
4
+ </head>
5
+ <summary>
6
+ <p>SUMMARY</p>
7
+ </summary>
8
+ <body>
9
+ <p>BODY</p>
10
+ </body>
@@ -0,0 +1,7 @@
1
+ <head>
2
+ <title>{{ title }}</title>
3
+ <meta name="publish-date" content="{{ date | date:'%Y-%m-%d %H:%M' }}"/>
4
+ </head>
5
+ <body>
6
+ <p>BODY</p>
7
+ </body>
@@ -0,0 +1,10 @@
1
+ <head>
2
+ <title>{{ title }}</title>
3
+ <meta name="publish-date" content="{{ date | date:'%Y-%m-%d %H:%M' }}"/>
4
+ </head>
5
+ <summary>
6
+ <p>SUMMARY</p>
7
+ </summary>
8
+ <body>
9
+ <p>BODY.</p>
10
+ </body>
@@ -0,0 +1,10 @@
1
+ <head>
2
+ <title>{{ title }}</title>
3
+ <meta name="publish-date" content="{{ date | date:'%Y-%m-%d %H:%M' }}"/>
4
+ </head>
5
+ <summary>
6
+ <p>SUMMARY</p>
7
+ </summary>
8
+ <body>
9
+ <p>BODY.</p>
10
+ </body>
@@ -0,0 +1,21 @@
1
+ site:
2
+ title: "My Site"
3
+ subtitle: "... is a testacular site. Ew, that doesn't sound right at all."
4
+ copyright: "&copy; 2008 Me. All rights reserved."
5
+ homepage: "pages/home"
6
+ base_url: "http://my.site"
7
+ theme: "default"
8
+ author:
9
+ name: "Me"
10
+ email: "my@email.com"
11
+
12
+ generator:
13
+ output: 'www'
14
+ relative_links: true
15
+ cleanup_xhtml: true
16
+ force_xhtml: false
17
+ tagging: true
18
+
19
+
20
+ stratus: # Don't touch this section!
21
+ version: 0.3
@@ -0,0 +1,8 @@
1
+ def awakeFromNib
2
+ window.setContentSize @generalPrefsView.frame.size
3
+ window.contentView.addSubview @generalPrefsView
4
+ window.title = "General Preferences"
5
+ @currentViewTag = 0
6
+ # Will use CoreAnimation for the panel changes:
7
+ window.contentView.wantsLayer = true
8
+ end
@@ -0,0 +1,14 @@
1
+ ib_action :selectPrefPanel do |sender|
2
+ tag = sender.tag
3
+ view, title = self.viewForTag(tag)
4
+ previousView, prevTitle = self.viewForTag(@currentViewTag)
5
+ @currentViewTag = tag
6
+ newFrame = self.newFrameForNewContentView(view)
7
+ window.title = "#{title} Preferences"
8
+ # Using an animation grouping because we may be changing the duration
9
+ NSAnimationContext.beginGrouping
10
+ # Call the animator instead of the view / window directly
11
+ window.contentView.animator.replaceSubview_with(previousView, view)
12
+ window.animator.setFrame_display newFrame, true
13
+ NSAnimationContext.endGrouping
14
+ end
@@ -0,0 +1,58 @@
1
+ <head>
2
+ <title>Animating NSViews in RubyCocoa</title>
3
+ <meta name="publish-date" content="2008-12-20 00:34"/>
4
+ </head>
5
+ <summary>
6
+ <p>Yesterday we talked about how to make nifty <a href="http://mattmccray.com/archive/2008/01/16/Selectable_Toolbar_Icons_in_Ru">selectable toolbars</a> like this:</p>
7
+
8
+ <p style="text-align:center;"><img src="http://www.mattmccray.com/images/selectable-toolbar.png" alt="selectable-toolbar.png" border="0" width="366" height="80" /></p>
9
+
10
+ <p>Now let's look at the finishing touch for our Preferences window; Animating the panel changes. We'll be flying through this at a pretty good clip, but don't worry. I'll provide the full source for your inspection.</p>
11
+ </summary>
12
+ <body>
13
+ <p>Yesterday we talked about how to make nifty <a href="http://mattmccray.com/archive/2008/01/16/Selectable_Toolbar_Icons_in_Ru">selectable toolbars</a> like this:</p>
14
+
15
+ <p style="text-align:center;"><img src="http://www.mattmccray.com/images/selectable-toolbar.png" alt="selectable-toolbar.png" border="0" width="366" height="80" /></p>
16
+
17
+ <p>Now let's look at the finishing touch for our Preferences window; Animating the panel changes. We'll be flying through this at a pretty good clip, but don't worry. I'll provide the full source for your inspection.</p>
18
+
19
+ <p>First off, let's add some new outlets to our window controller:</p>
20
+
21
+ {{ this.attachment.outlets | sourcecode}}
22
+
23
+ <p><img src="http://www.mattmccray.com/images/CustomView.png" alt="CustomView.png" border="0" width="135" height="54" align="right" /> Now in Interface Builder, we'll create the views for each preference pane by dragging Custom Views from the Library onto our Preferences.nib.</p>
24
+
25
+ <p><em>Note</em>: Be sure to drop the Custom Views on the main nib window in IB, not on the Preferences <code>NSWindow</code>. Your project (in IB) should look something like this:</p>
26
+
27
+ <div style="text-align:center;"><img src="http://www.mattmccray.com/images/Prefs-IB.png" alt="Prefs-IB.png" border="0" width="385" height="337" /></div>
28
+
29
+ <p>Hook up the outlets to the new views, and edit your preference panels to your heart's desire. From here, we go back to the code.</p>
30
+
31
+ <p><em>Tip</em>: Be sure to set the auto-sizing on your preference panels (the <code>NSView</code>s) so that it matches the <code>NSWindow</code>'s <code>contentView</code>.</p>
32
+
33
+ <p style="text-align:center;"><img src="http://www.mattmccray.com/images/Picture 5.png" alt="Picture 5.png" border="0" width="232" height="120"/></p>
34
+
35
+ <p>Next up are some helper methods for our window controller. I won't spend too much time explaining these, but they're pretty straight forward.</p>
36
+
37
+ {{ this.attachment.view_for_tag | sourcecode }}
38
+
39
+ <p><code>#viewForTag</code> actually returns our <code>NSView</code> and a title string.</p>
40
+
41
+ {{ this.attachment.new_frame | sourcecode }}
42
+
43
+ <p><code>#newFrameForNewContentView</code> calculates the new frame rectangle for the window based on the new view (preference pane).</p>
44
+
45
+ <p>Now we're ready to fill out our <code>selectPrefPanel</code> action:</p>
46
+
47
+ {{ this.attachment.ib_action | sourcecode }}
48
+
49
+
50
+ <p>Right on! Now we setup the initial pane when the window loads:</p>
51
+
52
+ {{ this.attachment.awake_from_nib | sourcecode }}
53
+
54
+ <p>That pretty much does it. Now you have a professional looking preferences window. So enough of those dang blasted <code>NSTabView</code>s!</p>
55
+
56
+ <p>Here's the completed <a href="http://pastie.textmate.org/140681">PreferencesController.rb</a>. Or, you can download the <a href="http://www.mattmccray.com/downloads/PreferencesExample.zip">full Xcode project</a>. (Requires Leopard, Xcode 3, and Interface Builder 3)</p>
57
+
58
+ <p>Happy coding!</p></body>
@@ -0,0 +1,10 @@
1
+ def newFrameForNewContentView(view)
2
+ newFrameRect = window.frameRectForContentRect(view.frame)
3
+ oldFrameRect = window.frame
4
+ newSize = newFrameRect.size
5
+ oldSize = oldFrameRect.size
6
+ frame = window.frame
7
+ frame.size = newSize
8
+ frame.origin.y = frame.origin.y - (newSize.height - oldSize.height)
9
+ frame
10
+ end
@@ -0,0 +1,2 @@
1
+ ib_outlets :generalPrefsView,
2
+ :advancedPrefsView
@@ -0,0 +1,6 @@
1
+ def viewForTag(tag)
2
+ case tag
3
+ when 0: [@generalPrefsView, "General"]
4
+ when 1: [@advancedPrefsView, "Advanced"]
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ <head>
2
+ <title>I'm the title</title>
3
+ <meta name="publish-date" content="2008-12-18 19:58"/>
4
+ </head>
5
+ <summary>
6
+ <p>SUMMARY</p>
7
+ </summary>
8
+ <body>
9
+ <p>I'm the main body.</p>
10
+ </body>
@@ -0,0 +1,5 @@
1
+ <!-- Browsers ignore script blocks with an unrecognized type. -->
2
+ <!-- Makes for pretty good inline template storage. -->
3
+ <script type="text/liquid" id="myOtherTemplate">
4
+ Hello, {{ current_user }}!
5
+ </script>
@@ -0,0 +1,35 @@
1
+ <head>
2
+ <title>Liquid.js, A Non-Evaling Template Engine in JavaScript</title>
3
+ <meta name="publish-date" content="2008-12-20 01:11"/>
4
+ </head>
5
+ <summary>
6
+ <p>SUMMARY</p>
7
+ </summary>
8
+ <body>
9
+ {% markdown %}
10
+ Of late, I’ve needed a robust JavaScript template engine that doesn’t use `eval` (and preferably not `with`). Also, I’ve always liked [Liquid][].
11
+
12
+ So, two plus two equals... JavaScript! Hah, you thought it was four, didn’t you? Well, that’s what you get for thinking.
13
+
14
+ Yeah, long story short, I ported Liquid to JavaScript. You can grab it from github (where else?) here: <http://github.com/darthapo/liquid.js>
15
+
16
+ I’m calling this version 0.1. It’s not battle tested yet, but I know it’ll work using Firefox 3+, Safari 3+, and Adobe Air 1.1.
17
+
18
+ So what are the differences between running the Ruby version and the JavaScript version? Well, as far as the templates themselves, nothing. It’s a full port, so all of Liquid’s default tags and filters are supported in Liquid.js. I even added a placeholder function that you can implement yourself (based on your own needs) to support the ‘include’ tag.
19
+
20
+ {{ this.attachment.liquid_example | sourcecode }}
21
+
22
+ An easy way to include template in a page is to use script elements, like this:
23
+
24
+ {{ this.attachment.html_test | sourcecode }}
25
+
26
+ Currently, Liquid.js requires [MooTools][]. Some of the things I’d like to polish up:
27
+
28
+ * Remove MooTools requirement, run entirely independent of any other js library
29
+ * Add Rhino for console-based testing
30
+ * Test, test, test on Internet <strike>Exploder</strike> Explorer
31
+
32
+ [Liquid]: http://liquidmarkup.org
33
+ [MooTools]: http://mootools.net/
34
+ {% endmarkdown %}
35
+ </body>
@@ -0,0 +1,14 @@
1
+ Liquid.readTemplateFile = function(path) {
2
+ var elem = $(path);
3
+ if(elem) {
4
+ return elem.innerHTML;
5
+ } else {
6
+ return path +" can't be found.";
7
+ // Or throw and error, or whatever you want...
8
+ }
9
+ }
10
+ var src = "{% include 'myOtherTemplate' with current_user %}";
11
+
12
+ var tmpl = Liquid.parse( src );
13
+
14
+ alert( tmpl.render({ current_user:'M@' }));
@@ -0,0 +1,7 @@
1
+ <head>
2
+ <title>About</title>
3
+ <meta name="sort_order" content="10" type="int">
4
+ </head>
5
+ <body>
6
+ <p>About this site.</p>
7
+ </body>