Skip to content

Commit

Permalink
Add to readme about config view_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nesquena committed May 10, 2012
1 parent eb6db09 commit 7975b75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Rabl.configure do |config|
# config.include_xml_root = false
# config.enable_json_callbacks = false
# config.xml_options = { :dasherize => true, :skip_types => false }
# config.view_paths = []
end
```

Expand All @@ -130,6 +131,9 @@ To cache just a single template, see the section titled 'Caching' below.
If `escape_all_output` is set to `true` and ActiveSupport is available, attribute output will be escaped using [ERB::Util.html_escape](http://corelib.rubyonrails.org/classes/ERB/Util.html).
Custom nodes will not be escaped, use `ERB::Util.h(value)`.

If `view_paths` is set to a path, this view path will be checked for every rabl template within your application.
Add to this path especially when including Rabl in an engine and using view paths within a another Rails app.

Note that the `json_engine` option uses [multi_json](http://intridea.com/2010/6/14/multi-json-the-swappable-json-handler) engine
defaults so that in most cases you **don't need to configure this** directly. If you wish to use yajl as
the primary JSON encoding engine simply add that to your Gemfile:
Expand All @@ -143,7 +147,7 @@ and RABL will automatically start using that engine for encoding your JSON respo

### Format Configuration ###

RABL supports configuration for MessagePack, BSON, and Plist. Check the
RABL supports configuration for MessagePack, BSON, and Plist. Check the
[Format Configuration](https://github.com/nesquena/rabl/wiki/Configuring-Formats) page for more details.

## Usage ##
Expand Down
4 changes: 1 addition & 3 deletions lib/rabl/partials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def object_to_hash(object, options={}, &block)
# Returns source for a given relative file
# fetch_source("show", :view_path => "...") => "...contents..."
def fetch_source(file, options={})
view_paths = Array(options[:view_path])
view_paths += Array(Rabl.configuration.view_paths)

view_paths = Array(options[:view_path]) + Array(Rabl.configuration.view_paths)
Rabl.source_cache(file, view_paths) do
file_path = if defined?(Padrino) && context_scope.respond_to?(:settings)
fetch_padrino_source(file, options)
Expand Down

0 comments on commit 7975b75

Please sign in to comment.