- Template not found errors properly show configured paths (@adam12 in #144)
- Compatible with Ruby 2.7/3.0 keyword argument handling (@flash-gordon in 4e7cefb)
- dry-equalizer dependency dropped in favor of dry-core (@solnic)
- Raise a
Dry::View::UndefinedConfigError
when a view is called but no paths have been configured (timriley in #130)
- [BREAKING] Move
Dry::View::Renderer::TemplateNotFoundError
toDry::View::TemplateNotFoundError
(timriley in #130) - [BREAKING]
Dry::View::UndefinedConfigError
is raised instead ofDry::View::UndefinedTemplateError
when a view is called but no template has been configured (timriley in #130) - Stop searching upwards through parent directories when rendering a view's template (as opposed to partials) (timriley in #130)
- Stop searching in
shared/
subdirectories when rendering a view's template (as opposed to partials) (timriley in #130) - Adjust template lookup cache keys to ensure no false hits (timriley in #130)
- Avoid a
SystemStackError
when a view is configured with a template that cannot be found on the filesystem (timriley in #129)
- [BREAKING]
Dry::View#call
now returns aDry::View::Rendered
instance, which carries both the rendered output (accessible via#to_s
or#to_str
) as well as all of the view's locals, wrapped in their view parts (accessible via#locals
or individually via#[]
) (timriley in #72) - [BREAKING] Added
Dry::View::PartBuilder
(renamed fromDry::View::Decorator
), which resolves part classes from a namespace configured via View'spart_namespace
setting. A custom part builder can be specified via a View'spart_builder
setting. (timriley in #80) - [BREAKING] Context classes can now declare decorated attributes just like part classes, via
.decorate
class-level API. Context classes are now required to inherit fromDry::View::Context
.Dry::View::Context
provides a#with
method for creating copies of itself while preserving the rendering details needed for decorated attributes to work (timriley in #89 and #91) - Customizable scope objects, which work like view parts, but instead of encapsulating a single value, they encapsulate a whole template or partial and all of its locals. Scopes can be created via
#scope
method in templates, parts, as well as scope classes themselves. Scope classes are resolved via a View'sscope_builder
setting, which defaults to an instance ofDry::View::ScopeBuilder
. - Added
inflector
setting to View, which is used by the part and scope builders to resolve classes for a given part or scope name. Defaults toDry::Inflector.new
(timriley in #80 and #90) - Exposures can be sent to the layout template when defined with
layout: true
option (GustavoCaso in #87) - Exposures can be left undecorated by a part when defined with
decorate: false
option (timriley in #88) - Part classes have access to the current template format via a private
#_format
method (timriley in #118) - Added "Tilt adapter" layer, to ensure a rendering engine compatible with dry-view's features is being used. Added adapters for "haml" and "erb" templates to ensure that "hamlit-block" and "erbse" are required and used as engines (unlike their more common counterparts, both of these engines support the implicit block capturing that is a central part of dry-view rendering behaviour) (timriley in #106)
- Added
renderer_engine_mapping
setting to View, which allows an explicit engine class to be provided for the rendering of a given type of template (e.g.config.renderer_engine_mapping = {erb: Tilt::ErubiTemplate}
) (timriley in #106)
- [BREAKING]
Dry::View::Controller
renamed toDry::View
(timriley in #115) - [BREAKING]
Dry::View
context
setting renamed todefault_context
(GustavoCaso in #86) - Exposure values are wrapped in their view parts before being made available as exposure dependencies (timriley in #80)
- Exposures can access current context object through
context:
block or method parameter (timriley in #119) - Improved performance due to caching various lookups (timriley and GustavoCaso in #97)
Part#inspect
output simplified to include only name and value (timriley in #98)- Attribute decoration in
Part
now achieved via a prepended module, which means it is possible to decorate an attribute provided by an instance method directly on the part class, which wasn't possible with the previousmethod_missing
-based approach (timriley in #110) Part
classes can be initialized with missingname:
andrendering:
values, which can be useful for unit testing Part methods that don't use any rendering facilities (timriley in #116)
- Preserve renderer options when chdir-ing (timriley in 889ac7b)
This version was yanked due to the release accidentally containing a batch of breaking changes from master.
- Preserve renderer options when chdir-ing (timriley in 889ac7b)
renderer_options
setting for configuring tilt-based renderer (liseki in #62)
- Part objects wrap values more transparently, via added
#respond_to_missing?
(liseki in #63)
- Only truthy view part attributes are decorated (timriley)
- Exposures are inherited from parent view controller classes (GustavoCaso)
- Support for parts with decorated attributes (timriley + GustavoCaso)
- Ability to easily create another part instance via
Part#new
(GustavoCaso)
- Raise a helpful error when trying to render a template or partial that cannot be found (GustavoCaso)
- Raise a helpful error when trying to call a view controller with no template configured (timriley)
- Allow a default to be specified for pass-through exposures with the
default:
option (GustavoCaso)
- [BREAKING] Exposures specify the input data they require using keyword arguments. This includes support for providing default values (via the keyword argument) for keys that are missing from the input data (GustavoCaso)
- Allow
Dry::View::Part
instances to be created without explicitly passing arenderer
. This is helpful for unit testing view parts that don't need to render anything (dNitza) - Partials can be nested within additional sub-directories by rendering them their relative path as their name, e.g.
render(:"foo/bar")
will look for afoo/_bar.html.slim
template within the normal template lookup paths (timriley)
This release reintroduces view parts in a more helpful form. You can provide your own custom view part classes to encapsulate your view logic, as well as a decorator for custom, shared behavior arouund view part wrapping.
- [BREAKING] Partial rendering in templates requires an explicit
render
method call instead of method_missing behaviour usinig the partial's name (e.g.<%= render :my_partial %>
instead of<%= my_partial %>
)
- Wrap all values passed to the template in
Dry::View::Part
objects - Added a
decorator
config toDry::View::Controller
, with a defaultDry::View::Decorator
that wraps the exposure values inDry::View::Part
objects (as above). Provide your own part classes by passing an:as
option to your exposures, e.g.expose :user, as: MyApp::UserPart
- Make input passthrough exposures (when there is no block or matching instance metod) return nil instead of raise in the case of a missing input key (timriley)
- Exposure blocks now have access to the view controller instance when they're called (timriley)
This release is a major reorientation for dry-view, and it should allow for more natural, straightforward template authoring.
- [BREAKING]
Dry::View::Layout
renamed toDry::View::Controller
. The "view controller" name better represents this object's job: to (timriley) - [BREAKING]
Dry::View::Controller
'sname
setting is replaced bytemplate
, which also supports falsey values to disable layout rendering entirely (timriley) - [BREAKING]
Dry::View::Controller
'sformats
setting is replaced bydefault_format
, which expects a simple string or symbol. The default value is:html
. (timriley) - [BREAKING]
Dry::View::Controller
'sroot
setting is replaced bypaths
, which can now accept an array of one or more directories. These will be searched for templates in order, with the first match winning (timriley) - [BREAKING]
Dry::View::Controller
'sscope
setting is removed and replaced bycontext
, which will be made available to all templates rendered from a view controller (layouts and partials inculded), not just the layout (timriley) - [BREAKING] View parts have been replaced by a simple
Scope
. Data passed to the templates can be accessed directly, rather than wrapped up in a view part. (timriley) - [BREAKING] With view parts removed, partials can only be rendered by top-level method calls within templates (timriley)
- Ruby version 2.1.0 is now the earliest supported version (timriley)
- Will render templates using any Tilt-supported engine, based on the template's final file extension (e.g.
hello.html.slim
will use Slim). For thread-safety, be sure to explicitly require any engine gems you intend to use. (timriley) expose
(andexpose_private
)Dry::View::Controller
class methods allow you to more easily declare and prepare the data for your template (timriley)- Added
Dry::View::Scope
, which is the scope used for rendering templates. This includes the data from the exposures along with the context object (timriley)
- Wrap
page
object exposed to layout templates in a part object, so it offers behaviour that is consistent with the part objects that template authors work with on other templates (timriley) - Render template content first, before passing that content to the layout. This makes "content_for"-style behaviours possible, where the template stores some data that the layout can then use later (timriley)
- Configure default template encoding to be UTF-8, fixing some issues with template rendering on deployed sites (gotar)
– Dry::View::Layout
supports multiple view template formats. Configure format/engine pairs (e.g. {html: :slim, text: :erb}
) on the formats
setting. The first format becomes the default. Request specific formats when calling the view, e.g. my_view.call(format: :text)
.
– Extracted from rodakase and renamed to dry-view. Rodakase::View
is now Dry::View
.