Sha256: ab6ecf25469f058ac227a9c862a8a711ce95570af98342d6ab285875984c63a6
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
module Landable class Partial def initialize(file) @file = file end def process @name = @file.gsub('/',' ').titlecase @description = "Defined in Source Code at #{@file}" @slug = @file.gsub(/[^\w]/, '_') @processed = true end def to_template process unless @processed template = Template.where(file: @file).first_or_initialize template.body = '' template.name = @name template.slug = @slug template.description = @description template.editable = false template.is_layout = false template.thumbnail_url ||= "http://placehold.it/300x200" # Save! template.save! # Publish! author = Author.find_or_create_by(username: 'TrogdorAdmin', email: 'trogdoradming@example.com', first_name: 'Marley', last_name: 'Pants') template.publish! author: author template end class << self def all files.map { |file| new(file) } end def files files = [] Landable.configuration.partials_to_templates.each do |path| files << path end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
landable-1.9.0.rc2 | lib/landable/partial.rb |
landable-1.9.0.rc1 | lib/landable/partial.rb |
landable-1.8.0 | lib/landable/partial.rb |
landable-1.7.1.rc1 | lib/landable/partial.rb |