Sha256: d5ed4fb7b9e008b3f23caa299023e8b5ff0fbbae01393a536f7a7123ba538fbf
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module Landable class Partial def initialize(file) @file = file end def process @name = @file.gsub('/', ' ').titlecase @description = "The Code for this template can be seen at #{@file} in the source code" @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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
landable-1.14.0 | lib/landable/partial.rb |
landable-1.13.2 | lib/landable/partial.rb |