markerb-pure 0.1.0

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.
@@ -0,0 +1,20 @@
1
+ Copyright 2011 PlataformaTec (blog.plataformatec.com.br)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Markerb Pure
2
+
3
+ This fork uses [Kramdown](https://github.com/gettalong/kramdown) for generating the HTML.
4
+ Since Kramdown is a fast, pure Ruby implementation, you can use markerb-pure also on JRuby.
5
+
6
+ # Markerb
7
+
8
+ Markerb allows you to render multipart e-mails from a single template.
9
+ The template is written in Markdown, which is delivered as a text part, but also rendered and delivered as an HTML part.
10
+
11
+ The usage is quite simple. Assuming you have a notifier as below:
12
+
13
+ class Notifier < ActionMailer::Base
14
+ def contact(recipient)
15
+ @recipient = recipient
16
+ mail(:to => @recipient, :from => "john.doe@example.com") do |format|
17
+ format.text
18
+ format.html
19
+ end
20
+ end
21
+ end
22
+
23
+ If you create a template at `app/views/notifier/contact.markerb`:
24
+
25
+ Multipart templates **rocks**, right <%= @recipient %>?!
26
+
27
+ It will generate two parts, one in text and another in html when delivered. Before we finish, here are a few things you might need to know:
28
+
29
+ * The `contact.markerb` template should not have a format in its name. Adding a format would make it unavailable to be rendered in different formats.
30
+
31
+ * The order of the parts matter. It is important for e-mail clients that you call `format.text` before you call `format.html`.
32
+
33
+ * Notice you can normally use ERb inside the template.
34
+
35
+ Enjoy!
36
+
37
+ ## Copyright and License
38
+
39
+ Created by the fine folks at PlataformaTec under the MIT-LICENSE (please check MIT-LICENSE file for more info).
40
+ Adapted to a pure markdown library for usage on JRuby by Michael Kessler.
@@ -0,0 +1,19 @@
1
+ require "rails/generators/erb/mailer/mailer_generator"
2
+
3
+ module Markerb
4
+ module Generators
5
+ class MailerGenerator < Erb::Generators::MailerGenerator
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ protected
9
+
10
+ def format
11
+ nil # Our templates have no format
12
+ end
13
+
14
+ def handler
15
+ :markerb
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ <%= class_name %>#<%= @action %>
2
+
3
+ <%%= @greeting %>, find me in app/views/<%= @path %>
@@ -0,0 +1 @@
1
+ require 'markerb'
@@ -0,0 +1,22 @@
1
+ require "action_view/template"
2
+ require "kramdown"
3
+ require "markerb/railtie"
4
+
5
+ module Markerb
6
+ class Handler
7
+ def erb_handler
8
+ @erb_handler ||= ActionView::Template.registered_template_handler(:erb)
9
+ end
10
+
11
+ def call(template)
12
+ compiled_source = erb_handler.call(template)
13
+ if template.formats.include?(:html)
14
+ "Kramdown::Document.new(begin;#{compiled_source};end).to_html"
15
+ else
16
+ compiled_source
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ ActionView::Template.register_template_handler :markerb, Markerb::Handler.new
@@ -0,0 +1,6 @@
1
+ module Markerb
2
+ class Railtie < ::Rails::Railtie
3
+ config.markerb = Markerb
4
+ config.app_generators.mailer :template_engine => :markerb
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Markerb
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: markerb-pure
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - "Jos\xC3\xA9 Valim"
14
+ - Michael Kessler
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-10-14 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: kramdown
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Multipart templates made easy with pure Markdown and ERb
36
+ email:
37
+ - contact@plataformatec.com.br
38
+ - michi@netzpiraten.ch
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/generators/markerb/mailer/mailer_generator.rb
47
+ - lib/generators/markerb/mailer/templates/view.markerb
48
+ - lib/markerb/railtie.rb
49
+ - lib/markerb/version.rb
50
+ - lib/markerb-pure.rb
51
+ - lib/markerb.rb
52
+ - MIT-LICENSE
53
+ - README.md
54
+ homepage: http://github.com/netzpirat/markerb-pure
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.6
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Multipart templates made easy with pure Markdown and ERb
87
+ test_files: []
88
+