class Middleman::Cli::Draft
This class provides a “draft” command for the middleman CLI.
Public Class Methods
exit_on_failure?()
click to toggle source
Tell Thor to exit with a nonzero exit code on failure
# File lib/middleman-blog-drafts/commands/draft.rb, line 22 def self.exit_on_failure? true end
source_root()
click to toggle source
Template files are relative to this file @return [String]
# File lib/middleman-blog-drafts/commands/draft.rb, line 17 def self.source_root File.dirname(__FILE__) end
Public Instance Methods
draft(title)
click to toggle source
# File lib/middleman-blog-drafts/commands/draft.rb, line 27 def draft(title) shared_instance = ::Middleman::Application.server.inst # This only exists when the config.rb sets it! unless shared_instance.blog.respond_to? :drafts raise Thor::Error.new "You need to activate the drafts extension in config.rb before you can create an article" end @title = title @slug = safe_parameterize title path_template = shared_instance.blog.drafts.source_template draft_path = apply_uri_template path_template, title: @slug draft_path << shared_instance.blog.options.default_extension template "draft.tt", File.join(shared_instance.source_dir, draft_path) end