vanilla 1.2 → 1.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/Rakefile +61 -60
  2. data/bin/vanilla +6 -35
  3. data/config.example.yml +6 -0
  4. data/config.ru +10 -0
  5. data/lib/defensio.rb +59 -0
  6. data/lib/tasks/vanilla.rake +173 -0
  7. data/lib/vanilla.rb +3 -10
  8. data/lib/vanilla/app.rb +48 -104
  9. data/lib/vanilla/console.rb +5 -19
  10. data/lib/vanilla/dynasnips/comments.rb +108 -0
  11. data/lib/vanilla/dynasnips/current_snip.rb +32 -0
  12. data/{pristine_app/soups → lib/vanilla}/dynasnips/debug.rb +3 -5
  13. data/lib/vanilla/dynasnips/edit.rb +60 -0
  14. data/lib/vanilla/dynasnips/edit_link.rb +20 -0
  15. data/{pristine_app/soups → lib/vanilla}/dynasnips/index.rb +2 -4
  16. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/kind.rb +12 -14
  17. data/{pristine_app/soups → lib/vanilla}/dynasnips/link_to.rb +0 -2
  18. data/lib/vanilla/dynasnips/link_to_current_snip.rb +16 -0
  19. data/lib/vanilla/dynasnips/login.rb +56 -0
  20. data/lib/vanilla/dynasnips/new.rb +14 -0
  21. data/lib/vanilla/dynasnips/notes.rb +42 -0
  22. data/{pristine_app/soups → lib/vanilla}/dynasnips/pre.rb +4 -6
  23. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/rand.rb +0 -2
  24. data/{pristine_app/soups → lib/vanilla}/dynasnips/raw.rb +5 -8
  25. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/url_to.rb +0 -0
  26. data/lib/vanilla/renderers/base.rb +22 -32
  27. data/lib/vanilla/renderers/bold.rb +2 -0
  28. data/lib/vanilla/renderers/erb.rb +2 -0
  29. data/lib/vanilla/renderers/markdown.rb +2 -0
  30. data/lib/vanilla/renderers/raw.rb +2 -0
  31. data/lib/vanilla/renderers/ruby.rb +5 -9
  32. data/lib/vanilla/renderers/textile.rb +2 -0
  33. data/lib/vanilla/request.rb +15 -16
  34. data/lib/vanilla/routes.rb +18 -5
  35. data/lib/vanilla/snip_reference.rb +534 -0
  36. data/lib/vanilla/snip_reference.treetop +48 -0
  37. data/lib/vanilla/snip_reference_parser.rb +99 -82
  38. data/lib/vanilla/snips/start.rb +28 -0
  39. data/lib/vanilla/snips/system.rb +77 -0
  40. data/lib/vanilla/snips/tutorial.rb +244 -0
  41. data/lib/vanilla/soup_with_timestamps.rb +21 -0
  42. data/public/hatch.png +0 -0
  43. data/public/javascripts/jquery.autogrow-textarea.js +54 -0
  44. data/public/javascripts/jquery.js +4376 -0
  45. data/public/javascripts/vanilla.js +22 -0
  46. data/spec/dynasnip_spec.rb +28 -0
  47. data/spec/renderers/base_renderer_spec.rb +40 -0
  48. data/spec/renderers/erb_renderer_spec.rb +27 -0
  49. data/spec/renderers/markdown_renderer_spec.rb +29 -0
  50. data/spec/renderers/raw_renderer_spec.rb +21 -0
  51. data/spec/renderers/ruby_renderer_spec.rb +59 -0
  52. data/spec/renderers/vanilla_app_detecting_renderer_spec.rb +35 -0
  53. data/spec/spec_helper.rb +70 -0
  54. data/spec/tmp/config.yml +2 -0
  55. data/spec/tmp/soup/current_snip.yml +15 -0
  56. data/spec/tmp/soup/system.yml +5 -0
  57. data/spec/vanilla_app_spec.rb +38 -0
  58. data/spec/vanilla_presenting_spec.rb +84 -0
  59. data/spec/vanilla_request_spec.rb +73 -0
  60. metadata +79 -170
  61. data/lib/vanilla/renderers.rb +0 -12
  62. data/lib/vanilla/renderers/haml.rb +0 -13
  63. data/lib/vanilla/static.rb +0 -28
  64. data/pristine_app/Gemfile +0 -3
  65. data/pristine_app/Gemfile.lock +0 -32
  66. data/pristine_app/README +0 -47
  67. data/pristine_app/config.ru +0 -26
  68. data/pristine_app/public/vanilla.css +0 -15
  69. data/pristine_app/soups/base/layout.snip +0 -18
  70. data/pristine_app/soups/base/start.snip +0 -19
  71. data/pristine_app/soups/dynasnips/current_snip.rb +0 -29
  72. data/pristine_app/soups/dynasnips/link_to_current_snip.rb +0 -14
  73. data/pristine_app/soups/dynasnips/page_title.rb +0 -9
  74. data/pristine_app/soups/extras/comments.rb +0 -78
  75. data/pristine_app/soups/tutorial/bad_dynasnip.snip +0 -8
  76. data/pristine_app/soups/tutorial/hello_world.snip +0 -20
  77. data/pristine_app/soups/tutorial/markdown_example.snip +0 -13
  78. data/pristine_app/soups/tutorial/snip.snip +0 -9
  79. data/pristine_app/soups/tutorial/soup.snip +0 -3
  80. data/pristine_app/soups/tutorial/test.snip +0 -30
  81. data/pristine_app/soups/tutorial/textile_example.snip +0 -11
  82. data/pristine_app/soups/tutorial/tutorial-another-snip.snip +0 -1
  83. data/pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip +0 -1
  84. data/pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown +0 -56
  85. data/pristine_app/soups/tutorial/tutorial-layout.snip +0 -56
  86. data/pristine_app/soups/tutorial/tutorial-links.snip +0 -4
  87. data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +0 -77
  88. data/pristine_app/soups/tutorial/tutorial.snip.markdown +0 -69
  89. data/pristine_app/soups/tutorial/vanilla-rb.snip +0 -16
  90. data/pristine_app/soups/tutorial/vanilla.snip +0 -8
  91. data/test/dynasnip_test.rb +0 -42
  92. data/test/dynasnips/link_to_current_snip_test.rb +0 -19
  93. data/test/dynasnips/link_to_test.rb +0 -27
  94. data/test/dynasnips/page_title_test.rb +0 -19
  95. data/test/renderers/base_renderer_test.rb +0 -43
  96. data/test/renderers/erb_renderer_test.rb +0 -29
  97. data/test/renderers/haml_renderer_test.rb +0 -35
  98. data/test/renderers/markdown_renderer_test.rb +0 -31
  99. data/test/renderers/raw_renderer_test.rb +0 -23
  100. data/test/renderers/ruby_renderer_test.rb +0 -59
  101. data/test/snip_inclusion_test.rb +0 -56
  102. data/test/snip_reference_parser_test.rb +0 -123
  103. data/test/test_helper.rb +0 -75
  104. data/test/vanilla_app_test.rb +0 -83
  105. data/test/vanilla_presenting_test.rb +0 -125
  106. data/test/vanilla_request_test.rb +0 -87
@@ -1,56 +0,0 @@
1
- {tutorial-links}
2
-
3
- Layouts
4
- =======
5
-
6
- Since you almost certainly want your site to look good, one of the first things you'll want to change in your vanilla site is the layout.
7
-
8
- When the browser requests a snip, normally vanilla will present it within a _layout_ template. This would typically include a header, a footer, and any other peripheral markup that shouldn't be within the content of the snip itself. If you're familiar with the construction of web applications, this will be exactly as you expect.
9
-
10
- Layouts are just like any other snip - they can be sent through a renderer, and include other snips. The default layout snip is called, predictable, `layout.snip`, and here's the content:
11
-
12
- {raw layout}
13
-
14
- When you request `/start`, this is the snip that's actually rendered first. If this snip was just text, that's all that would be returned; however, there are some dynasnip calls in here which help us actually return the content that the user requested.
15
-
16
-
17
- `current_snip`
18
- --------------
19
-
20
- The most significant is the call to `current_snip`. This figures out what snip was actually requested (e.g. if the url is `/start`, it's the {link_to start} snip), and renders it in place.
21
-
22
- Here's the source of `current_snip`:
23
-
24
- {raw current_snip}
25
-
26
- The default case, as in our layout, is `app.render(app.request.snip, app.request.part)` - it delegates rendering back to the application, which then takes care of processing `start` using the right renderer and so on. This method call returns the fully rendered string, and vanilla replaces the call to the dynasnip with that output, placing our snip in the appropriate place in the layout.
27
-
28
-
29
- Other dynas
30
- -----------
31
-
32
- Of course, you can put other plain content in your layout, and other dynasnips too. In the provided layout there are calls to two other dynasnips.
33
-
34
- The first is `page_title`, which simply places a (hopefully) meaningful string in the title element of the page. Snips can set the title to be used by defining a `:page_title` attribute. As usual, the source explains it more clearly:
35
-
36
- {raw page_title}
37
-
38
- The second dynasnip used is `link_to_current_snip`, which returns an HTML link to the snip that's currently being rendered. I'll let you figure out how to view the source yourself.
39
-
40
-
41
- Other layouts
42
- -------------
43
-
44
- Vanilla looks for a snip called `layout` by default, but this can be changed by passing in a `:default_layout` option to `Vanilla::App.new`, e.g.
45
-
46
- Vanilla::App.new(:default_layout => "my_layout")
47
-
48
-
49
- You can also override the layout on a per-snip basis, simply by setting the `:layout` attribute of the snip to the name of the layout snip to use instead.
50
-
51
- Finally, if you implement a custom renderer class (see {link_to tutorial-renderers, "the renderers tutorial"}), you can also specify a layout to be used when the requested snip invokes that renderer. This can be useful if you have a particular kind of content that requires a different layout entirely.
52
-
53
- {tutorial-links}
54
-
55
- :render_as: Markdown
56
- :page_title: Tutorial - Layout
@@ -1,4 +0,0 @@
1
- {link_to tutorial}
2
- {link_to tutorial-layout}
3
- {link_to tutorial-renderers}
4
- {link_to tutorial-dynasnips}
@@ -1,77 +0,0 @@
1
- {tutorial-links}
2
-
3
- Renderers
4
- =========
5
-
6
- As well as the flexibility to combine pieces of content, another reason {link_to vanilla-rb} is more *interesting* than simpler wiki-ish software is that each piece of content can be processed by arbitrarily complex software before it is composed.
7
-
8
- In its simplest form, this means that some content can be written in one format (say, raw HTML) whereas other content can be written in different formats (like Textile or Markdown for richer content). You could write one blog post in Textile, and the next one in Markdown, without any issues, depending on what best suits your purpose.
9
-
10
- This is one of the principle drivers behind {link_to vanilla-rb}; you shouldn't have to make an upfront decision about how best to structure your all of your content.
11
-
12
- This has been covered generally in the {link_to tutorial, main tutorial}, but here we'll go into a bit more detail.
13
-
14
- Defining a renderer for a snip
15
- -------------------
16
-
17
- The renderer used for a snip is determined in the following manner
18
-
19
- 1. Using the snip `extension` attribute
20
- 2. Using the snip `render_as` attribute
21
- 3. Using the default renderer
22
-
23
- The snip `extension` is an attribute generated by the {link_to soup} library, which roughly corresponds to the file extension of the snip itself. So, if your snip is stored in a file called `my-schnip.markdown`, the `extension` property will be `markdown`. If the filename is `my-schnip.snip.markdown`, the `extension` is still just `markdown`.
24
-
25
- To determine the actual renderer from this attributes, a lookup hash is used, mapping these strings onto Ruby classes. The default is something like this:
26
-
27
- {
28
- "base" => Vanilla::Renderers::Base,
29
- "markdown" => Vanilla::Renderers::Markdown,
30
- "bold" => Vanilla::Renderers::Bold,
31
- "erb" => Vanilla::Renderers::Erb,
32
- "rb" => Vanilla::Renderers::Ruby,
33
- "ruby" => Vanilla::Renderers::Ruby,
34
- "haml" => Vanilla::Renderers::Haml,
35
- "raw" => Vanilla::Renderers::Raw,
36
- "textile" => Vanilla::Renderers::Textile
37
- }
38
-
39
-
40
- Adding renderers
41
- ----------------
42
-
43
- New renderers can be added as part of the application configuration:
44
-
45
- Vanilla::App.new(:renderers => {
46
- "rdoc" => MyRenderers::RDoc
47
- })
48
-
49
- These will be added to the lookup, and can also used to override the defaults (changing the renderer for "markdown" snips to use RDiscount, or Redcarpet, for example).
50
-
51
-
52
- Writing new renderers
53
- ---------------------
54
-
55
- The simplest renderer inherits from `Vanilla::Renderers::Base`, and reimplement the `process_text` method:
56
-
57
- module Vanilla::Renderers
58
- class Bold < Base
59
- def process_text(content)
60
- "<b>#{content}</b>"
61
- end
62
- end
63
- end
64
-
65
- It is passed a string (either the selected snip's "content" attribute, or some other explicitly requested attribute), and should return that content in its rendered form. The `Vanilla::Renderers::Markdown` renderer shows this more clearly:
66
-
67
- module Vanilla::Renderers
68
- class Markdown < Base
69
- def process_text(content)
70
- BlueCloth.new(content).to_html
71
- end
72
- end
73
- end
74
-
75
- There are a number of other methods which can be overridden by custom renderers, but these are beyond the scope of this tutorial; the best way to learn is to look at the set of provided renderers (such as the Erb and Haml ones) and work from there.
76
-
77
- {tutorial-links}
@@ -1,69 +0,0 @@
1
- {tutorial-links}
2
-
3
- Snips - the basic concept
4
- ------------
5
-
6
- Firstly, open the raw contents of this snip - either in your editor (search for `vanilla-rb-tutorial.snip`), or by opening <a href="{current_snip name}.raw">this snip in raw format</a> in a new window or tab. Ready? OK.
7
-
8
- Every piece of information displayed here is stored as a {link_to snip}. Snips, within their contents, can also reference other snips. When you request a snip, it will render into a page (or another kind of response), and also render any snips that it internally references.
9
-
10
- For example, consider the snip {link_to tutorial-basic-snip-inclusion}:
11
-
12
- {raw tutorial-basic-snip-inclusion}
13
-
14
- When this snip is rendered, it appears like this:
15
-
16
- > {tutorial-basic-snip-inclusion}
17
-
18
- Notice the use of curly brackets to reference one snip from inside another. {link_to vanilla-rb} finds these references to snips, then renders that snip and replaces it in the first snip. Neat!
19
-
20
- Renderers
21
- --------
22
-
23
- The way that a snip is rendered depends on whether or not it has an extension, or a `render_as` attribute set. For instance, the extention of this snip is `{current_snip extension}`, and the `render_as` property of `markdown_example` is `Markdown`. Scroll to the bottom of the raw markdown_example snip in your editor, and you'll see this being declared.
24
-
25
- This means that the `content` of this snip will be passed through `Vanilla::Renderers::Markdown` before it is then rendered to the page. There are several different renders provided by Vanilla.rb at the moment:
26
-
27
- * Markdown - as described above
28
- * Textile - which performs similarly for Textile. This means that you can mix how you write the content of snips!
29
- * Raw - which simply returns the content of the snip, as-is. If you attach a `.raw` extension to this url, you'll see it in action
30
- * Bold - simply wraps the content in bold. It's a demo, essentially.
31
- * Erb - passes the snip contents through Ruby's `Erb` library. It also makes some information available for use by ruby code within the snip's contents
32
- * Ruby - parses the snips content as Ruby itself.
33
-
34
- You can see a lot of these renderers being exercised in the {link_to test} snip.
35
-
36
- It's using this last renderer that a second concept of Vanilla is implemented - dynasnips.
37
-
38
-
39
- Dynasnips
40
- --------
41
-
42
- Because the curly braces simply cause a snip to be rendered, we can use this in conjunction with the Ruby renderer to run actual code. For instance, in the snip above:
43
-
44
- {raw tutorial-basic-snip-inclusion}
45
-
46
- we can see a reference to the `link_to` snip - <tt>&#123;link\_to snip&#125;</tt>.
47
-
48
- Lets look at the raw content of `link_to`:
49
-
50
- {raw link_to}
51
-
52
- As you can see, it simply refers to the Ruby class `LinkTo`, which is contained within the vanilla-rb codebase. When the Ruby renderer is called, expects the given code to evaulate to a Ruby class. It then instantiates the class, and calls a `handle` method on the instance, passing it any other arguments from the snip inclusion. So, in the case of <tt>&#123;link\_to snip&#125;</tt>, the only argument is `snip`.
53
-
54
- ### Included Dynasnips
55
-
56
- Vanilla.rb includes a number of dynasnips by default. Here are a couple:
57
-
58
- * `link_to`, to produce a link to another snip
59
- * `raw`, which displays the raw contents of a snip
60
- * `index`, which shows all of the available snips: {link_to index}
61
- * ... and several others.
62
-
63
-
64
- Anyway - that should be enough to get you started.
65
-
66
- {tutorial-links}
67
-
68
-
69
- :updated_at: 2011-04-28 16:21:00 +01:00
@@ -1,16 +0,0 @@
1
- Vanilla.rb is the software powering this site. It's a sort-of wiki/bliki thing, based on {link_to vanilla}.
2
-
3
- Here's the [introductory blog post][3].
4
-
5
- It's developed on [github][1], and has a [lighthouse bug tracker][2]. At the moment it's not very well documented, since I'm exploring how the concept might work and the internals are subject to change. However, please do play around with it.
6
-
7
- Here's the tutorial (helpfully included from {link_to tutorial}).
8
-
9
- {tutorial}
10
-
11
-
12
- [1]: http://github.com/lazyatom/vanilla
13
- [2]: http://lazyatom.lighthouseapp.com/projects/11797-vanilla/tickets
14
- [3]: http://interblah.net/introducing-vanilla-rb
15
-
16
- :render_as: Markdown
@@ -1,8 +0,0 @@
1
- The bliki upon which {link_to vanilla-rb} is based, written by [Christian Langreiter][1]
2
-
3
- [Official Web HQ][2]
4
-
5
- [1]: http://www.langreiter.com
6
- [2]: http://www.vanillasite.at
7
-
8
- :render_as: Markdown
@@ -1,42 +0,0 @@
1
- require "test_helper"
2
- require 'vanilla/dynasnip'
3
-
4
- describe Dynasnip do
5
- context "when storing attributes" do
6
-
7
- class ::TestDyna < Dynasnip
8
- attribute :test_attribute, "test attribute content"
9
- end
10
-
11
- should "make the attribute available as an instance method" do
12
- assert_equal "test attribute content", TestDyna.new(@app).test_attribute
13
- end
14
-
15
- should "store the attribute in the soup" do
16
- @app.soup << TestDyna.snip_attributes
17
- assert_equal "test attribute content", @app.soup['test_dyna'].test_attribute
18
- end
19
-
20
- should "allow the attribute to be overriden by the soup contents" do
21
- @app.soup << TestDyna.snip_attributes
22
- snip = @app.soup['test_dyna']
23
- snip.test_attribute = "altered content"
24
- snip.save
25
-
26
- assert_equal "altered content", TestDyna.new(@app).test_attribute
27
- end
28
- end
29
-
30
- context "when rendering usage" do
31
- class ::ShowUsage < Dynasnip
32
- usage "This is the usage"
33
- def handle
34
- usage
35
- end
36
- end
37
-
38
- should "show the usage defined in the snip" do
39
- assert_equal "This is the usage", ShowUsage.new(@app).handle
40
- end
41
- end
42
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/dynasnips", __FILE__)
3
- require "link_to_current_snip"
4
-
5
- context "The link_to_current_snip dynasnip" do
6
- setup do
7
- @app.soup << LinkToCurrentSnip.snip_attributes
8
- create_snip :name => "test", :content => "test {link_to_current_snip}"
9
- end
10
-
11
- should "render a link to the snip that was requested" do
12
- assert_response_body %{test <a href="/test">test</a>}, "/test"
13
- end
14
-
15
- should "render a link to the snip that was requested even if it isn't the snip that included the dyna" do
16
- create_snip :name => "othertest", :content => "othertest {test}"
17
- assert_response_body %{othertest test <a href="/othertest">othertest</a>}, "/othertest"
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/dynasnips", __FILE__)
3
- require "link_to"
4
-
5
- context "The link_to dynasnip" do
6
- setup do
7
- create_snip :name => "start", :content => "hello"
8
- end
9
-
10
- should "render a link to a snip that exists" do
11
- assert_equal %{<a href="/start">start</a>}, render_dynasnip(LinkTo, "start")
12
- end
13
-
14
- should "allow specification of the link text" do
15
- assert_equal %{<a href="/start">the start snip</a>}, render_dynasnip(LinkTo, "start", "the start snip")
16
- end
17
-
18
- should "mark snips that are missing with a class" do
19
- assert_equal %{<a class="missing" href="/missing">missing</a>}, render_dynasnip(LinkTo, "missing")
20
- end
21
-
22
- private
23
-
24
- def render_dynasnip(klass, *args)
25
- klass.new(@app).handle(*args)
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/dynasnips", __FILE__)
3
- require "page_title"
4
-
5
- context "The page_title dynasnip" do
6
- setup do
7
- @app.soup << PageTitle.snip_attributes
8
- end
9
-
10
- should "render as the requested snip name if that snip has no title" do
11
- create_snip :name => "test", :content => "{page_title}"
12
- assert_response_body %{test}, "/test"
13
- end
14
-
15
- should "render as the requested snip's page_title when that attribute is present" do
16
- create_snip :name => "test", :content => "{page_title}", :page_title => "This is a test"
17
- assert_response_body %{This is a test}, "/test"
18
- end
19
- end
@@ -1,43 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Vanilla::Renderers::Base do
4
- setup do
5
- create_snip(:name => "test", :content => "content content", :part => "part content")
6
- end
7
-
8
- should "render the contents part of the snip as it is" do
9
- assert_response_body "content content", "/test"
10
- end
11
-
12
- should "render the specified part of the snip" do
13
- assert_response_body "part content", "/test/part"
14
- end
15
-
16
- should "include the contents of a referenced snip" do
17
- create_snip(:name => "snip_with_inclusions", :content => "loading {test}")
18
- assert_response_body "loading content content", "/snip_with_inclusions"
19
- end
20
-
21
- should "be able to render a snip attribute" do
22
- create_snip(:name => "snip_with_inclusions", :content => "loading {test.part}")
23
- assert_response_body "loading part content", "/snip_with_inclusions"
24
- end
25
-
26
- should "perform snip inclusion when rendering a part" do
27
- create_snip(:name => "snip_with_inclusions", :content => "other content", :part => "loading {test}")
28
- assert_response_body "loading content content", "/snip_with_inclusions/part"
29
- end
30
-
31
- should "include other snips using their renderers" do
32
- create_snip(:name => "including_snip", :content => "lets include {another_snip}")
33
- create_snip(:name => "another_snip", :content => "blah", :render_as => "Bold")
34
- assert_equal "lets include <b>blah</b>", response_body_for("/including_snip").gsub(/\s+/, ' ')
35
- end
36
-
37
- context "when trying to include a missing snip" do
38
- should "return a string describing the missing snip" do
39
- create_snip(:name => 'blah', :content => 'include a {missing_snip}')
40
- assert_response_body "include a [snip 'missing_snip' cannot be found]", "/blah"
41
- end
42
- end
43
- end
@@ -1,29 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Vanilla::Renderers::Erb do
4
- context "when rendering" do
5
- should "insert evaluated Erb content into the snip" do
6
- erb_snip(:name => "test", :content => "<%= 1 + 2 %>")
7
- assert_response_body "3", "/test"
8
- end
9
-
10
- should "evaluate Erb content in the snip" do
11
- erb_snip(:name => "test", :content => "<% if false %>monkey<% else %>donkey<% end %>")
12
- assert_response_body "donkey", "/test"
13
- end
14
-
15
- should "expose the snip as an instance variable" do
16
- erb_snip(:name => "test", :content => "<%= @snip.name %>")
17
- assert_response_body "test", "/test"
18
- end
19
-
20
- should "expose the app as an instance variable" do
21
- erb_snip(:name => "test", :content => "<%= @app.class.name %>")
22
- assert_response_body "Vanilla::App", "/test"
23
- end
24
- end
25
-
26
- def erb_snip(params)
27
- create_snip(params.merge(:render_as => "Erb"))
28
- end
29
- end
@@ -1,35 +0,0 @@
1
- require 'test_helper'
2
- require 'haml'
3
-
4
- describe Vanilla::Renderers::Haml do
5
- context "when rendering" do
6
- should "render Haml into HTML" do
7
- haml_snip(:name => "test", :content => "#hello\n stuff")
8
- assert_response_body %{<div id='hello'>\n stuff\n</div>}, "/test"
9
- end
10
-
11
- should "insert evaluated Haml content into the snip" do
12
- haml_snip(:name => "test", :content => "= 1 + 2")
13
- assert_response_body "3", "/test"
14
- end
15
-
16
- should "evaluate Erb content in the snip" do
17
- haml_snip(:name => "test", :content => "- if false\n monkey\n- else\n donkey")
18
- assert_response_body "donkey", "/test"
19
- end
20
-
21
- should "expose the snip as an instance variable" do
22
- haml_snip(:name => "test", :content => "= @snip.name")
23
- assert_response_body "test", "/test"
24
- end
25
-
26
- should "expose the app as an instance variable" do
27
- haml_snip(:name => "test", :content => "= @app.class.name")
28
- assert_response_body "Vanilla::App", "/test"
29
- end
30
- end
31
-
32
- def haml_snip(params)
33
- create_snip(params.merge(:render_as => "Haml"))
34
- end
35
- end