Configuration
Esse::Config#search_view_path
Added to Esse::Config. Default: Pathname('app/searches').
Esse.configure do |config| config.search_view_path = 'app/searches' # String config.search_view_path = Pathname('searches') # PathnameendRead back:
Esse.config.search_view_path # => PathnameEsse::Jbuilder::Template
Renders a Jbuilder block or a .json.jbuilder file into a Hash, independent of Rails.
.call(view_filename = nil, **assigns, &block) → Hash
- If a block is given, renders the block.
- If
view_filenameis given, renders the file fromsearch_view_path. assignsare exposed as@variablesin the template.
# From a blockbody = Esse::Jbuilder::Template.call do |json| json.query { json.match { json.set! 'name', 'John' } }end
# From a filebody = Esse::Jbuilder::Template.call('cities/search', name: 'Chicago')Instance methods
initialize(view_filename = nil, **assigns)to_hash(&block)— the actual rendering.
Esse::Jbuilder::ViewTemplate
Renders a Jbuilder template through Rails’ ActionView pipeline. Requires Rails (ActionView) to be loaded. Supports partial!, helpers, and full view lookup.
.call(view_filename, assigns = {}) → Hash
body = Esse::Jbuilder::ViewTemplate.call('cities/search', name: 'Chicago')Class attributes
symbolize_keys— defaultfalse. Whentrue, the resulting hash uses Symbol keys.
Instance methods
initialize(view_filename, assigns = {})to_hash— renders via ActionView.
Esse::Jbuilder::WithAssigns
Internal Jbuilder subclass. Used to inject @assigns into the template context.
__assign(key)— retrieve an assigned variable by name.
You don’t need to use this directly.
Esse::Jbuilder::SearchRequestView
Internal ActionView base class used by ViewTemplate for the render context.
.lookup_context(class-level, memoized) — returns theActionView::LookupContext.
Not part of the public API.
Integration points
On load the gem:
- Extends
Esse::Configwithsearch_view_path/search_view_path=. - Prepends
Esse::Jbuilder::SearchQuery::InstanceMethodsintoEsse::Search::Query, teaching the query to accept Jbuilder blocks.
No explicit plugin :jbuilder call is needed — just require 'esse/jbuilder' (or have it in your Gemfile).