Skip to content

Commit

Permalink
Merge pull request #122 from yous/patch-tomdoc
Browse files Browse the repository at this point in the history
Fix TomDoc
  • Loading branch information
dasch committed Nov 21, 2014
2 parents a4f3e1d + e815899 commit e0162d6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In order to keep the Curly code base nice and tidy, please observe these best pr
- Document any unclear things in the code. Even better, don't make the code do unclear things.
- Use the coding style already present in the code base.
- Make your commit messages precise and to the point. Add a short summary (50 chars max) followed by a blank line and then a longer description, if necessary, e.g.

> Make invalid references raise an exception
>
> In order to avoid nasty errors when doing stuff, make the Curly compiler
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ class Posts::CommentPresenter < Curly::Presenter
def author_link
link_to @comment.author.name, @comment.author, rel: "author"
end

def deletion_link
link_to "Delete", @comment, method: :delete
end

def time_ago
time_ago_in_words(@comment.created_at)
end

def author?
@comment.author == current_user
end
Expand Down Expand Up @@ -268,7 +268,7 @@ the template inline. A simple template could look like:
<b>Name: </b> {{name_field}}<br>
<b>E-mail: </b> {{email_field}}<br>
{{comment_field}}

{{submit_button}}
{{/comment_form}}
```
Expand All @@ -284,15 +284,15 @@ class PostPresenter < Curly::Presenter
presents :post
def title; @post.title; end
def body; markdown(@post.body); end

# A context block method *must* take a block argument. The return value
# of the method will be used when rendering. Calling the block argument will
# render the nested template. If you pass a value when calling the block
# argument it will be passed to the presenter.
def comment_form(&block)
form_for(Comment.new, &block)
end

# The presenter name is automatically deduced.
class CommentFormPresenter < Curly::Presenter
# The value passed to the block argument will be passed in a parameter named
Expand Down Expand Up @@ -404,18 +404,18 @@ a component:
```ruby
class Posts::ShowPresenter < Curly::Presenter
presents :post

def title
@post.title
end

def author_link
# You can call any Rails helper from within a presenter instance:
link_to author.name, profile_path(author), rel: "author"
end

private

# Private methods are not available to the template, so they're safe to
# use.
def author
Expand Down Expand Up @@ -464,12 +464,12 @@ class ApplicationLayout < Curly::Presenter
def title
"You can use methods just like in any other presenter!"
end

def sidebar
# A view can call `content_for(:sidebar) { "some HTML here" }`
yield :sidebar
end

def body
# The view will be rendered and inserted here:
yield
Expand Down
1 change: 0 additions & 1 deletion lib/curly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# end
#
# See Curly::Presenter for more information on presenters.
#
module Curly
VERSION = "2.1.1"

Expand Down
2 changes: 1 addition & 1 deletion lib/curly/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def closed_by?(component)
false
end
end

class Block
attr_reader :type, :component, :nodes

Expand Down
15 changes: 8 additions & 7 deletions lib/curly/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Presenter
#
# context - An ActionView::Base context.
# options - A Hash of options given to the presenter.
#
def initialize(context, options = {})
@_context = context
options.stringify_keys!
Expand All @@ -63,7 +62,7 @@ def initialize(context, options = {})
# template is rendered. One use case is to call `content_for` in order
# to inject content into other templates, e.g. a layout.
#
# Example
# Examples
#
# class Posts::ShowPresenter < Curly::Presenter
# presents :post
Expand Down Expand Up @@ -189,13 +188,14 @@ def presenter_for_name(name)
end
end

# Whether a component is available to templates rendered with the presenter.
# Whether a component is available to templates rendered with the
# presenter.
#
# Templates have components which correspond with methods defined on
# the presenter. By default, only public instance methods can be
# referenced, and any method defined on Curly::Presenter itself cannot be
# referenced. This means that methods such as `#cache_key` and #inspect are
# not available. This is done for safety purposes.
# referenced. This means that methods such as `#cache_key` and #inspect
# are not available. This is done for safety purposes.
#
# This policy can be changed by overriding this method in your presenters.
#
Expand All @@ -217,7 +217,7 @@ def available_components

# The set of view paths that the presenter depends on.
#
# Example
# Examples
#
# class Posts::ShowPresenter < Curly::Presenter
# version 2
Expand Down Expand Up @@ -257,7 +257,8 @@ def version(version = nil)
@version || 0
end

# The cache key for the presenter class. Includes all dependencies as well.
# The cache key for the presenter class. Includes all dependencies as
# well.
#
# Returns a String cache key.
def cache_key
Expand Down
3 changes: 1 addition & 2 deletions lib/curly/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Curly
#
# The Scanner goes through the template piece by piece, extracting tokens
# until the end of the template is reached.
#
class Scanner
CURLY_START = /\{\{/
CURLY_END = /\}\}/
Expand All @@ -27,7 +26,7 @@ class Scanner
#
# source - The String source of the template.
#
# Example
# Examples
#
# Curly::Scanner.scan("hello {{name}}!")
# #=> [[:text, "hello "], [:component, "name"], [:text, "!"]]
Expand Down

0 comments on commit e0162d6

Please sign in to comment.