Sha256: d759e0ef1630d8457a1cc7aa0299bd90e1627595391a6a9adc5998d2f66fd9e1
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
require File.join(__FILE__, '../../base') module Alchemy module Generators class ElementsGenerator < Base desc "This generator generates your elements view partials." source_root File.expand_path('templates', File.dirname(__FILE__)) def create_directory @elements_dir = "#{Rails.root}/app/views/alchemy/elements" empty_directory @elements_dir end def create_partials @elements = load_alchemy_yaml('elements.yml') @elements.each do |element| @element = element @contents = element["contents"] || [] if element["name"] =~ /\A[a-z0-9_-]+\z/ @element_name = element["name"].underscore else raise "Element name '#{element['name']}' has wrong format. Only lowercase and non whitespace characters allowed." end conditional_template "editor.html.#{template_engine}", "#{@elements_dir}/_#{@element_name}_editor.html.#{template_engine}" conditional_template "view.html.#{template_engine}", "#{@elements_dir}/_#{@element_name}_view.html.#{template_engine}" end if @elements end end end end
Version data entries
6 entries across 6 versions & 1 rubygems