pakyow-presenter/lib/presenter/config/presenter.rb in pakyow-presenter-0.8.0 vs pakyow-presenter/lib/presenter/config/presenter.rb in pakyow-presenter-0.9.0

- old
+ new

@@ -1,61 +1,36 @@ -module Pakyow - module Config - class Presenter - Config::Base.register_config(:presenter, self) +Pakyow::Config.register(:presenter) { |config| - class << self - attr_accessor :javascripts, :stylesheets, :view_stores, :default_views, - :scope_attribute, :prop_attribute, :container_attribute, :template_dirs + # registered view stores + config.opt :view_stores, lambda { + @stores ||= { + default: File.join(Pakyow::Config.app.root, 'app', 'views') + } + } - # Location of javascripts - def javascripts - @javascripts || '/javascripts' - end + # the default view for each view store + config.opt :default_views, { default: 'pakyow.html' } - # Location of stylesheets - def stylesheets - @stylesheets || '/stylesheets' - end + # a convenience option to lookup the default_view for a view store by name + config.opt :default_view, lambda { |store_name| + views = Pakyow::Config.presenter.default_views + views.fetch(store_name) { views[:default] } + } - def view_stores - @view_stores ||= {:default => "#{Config::Base.app.root}/app/views"} - end + # the default template dir for each view store + config.opt :template_dirs, { default: '_templates' } - def default_views(store_name = nil) - @default_views ||= {:default => "pakyow.html"} - end + # a convenience option to lookup the template_dir for a view store by name + config.opt :template_dir, lambda { |store_name| + dirs = Pakyow::Config.presenter.template_dirs + dirs.fetch(store_name) { dirs[:default] } + } - # Returns the default view for store, or default. - # - def default_view(store_name) - views = default_views - views.key?(store_name) ? views[store_name] : views[:default] - end + # the attribute expected for scope definitions + config.opt :scope_attribute, 'data-scope' - def template_dirs(store_name = nil) - @template_dirs ||= {:default => '_templates'} - end + # the attribute expected for prop definitions + config.opt :prop_attribute, 'data-prop' - # Returns the default template dir for store, or default. - # - def template_dir(store_name) - dirs = template_dirs - dirs.key?(store_name) ? dirs[store_name] : dirs[:default] - end - - def scope_attribute - @scope_attribute || "data-scope" - end - - def prop_attribute - @prop_attribute || "data-prop" - end - - def container_attribute - @container_attribute || "data-container" - end - - end - end - end -end + # the document class used to parse and render views + config.opt :view_doc_class, StringDoc +}