Skip to content

Commit

Permalink
Include helpers
Browse files Browse the repository at this point in the history
Why:

So we don't have to manually do it in the readme.

This change addresses the need by:

Include helpers in engine.
  • Loading branch information
Mrjaco12 committed Oct 20, 2015
1 parent dec5780 commit f9bb59d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,6 @@ class PagesController < ApplicationController
end
end
```
#### Helper
Create `app/helpers/application_helper.rb` and update it to match the following:
```ruby
module ApplicationHelper
def add_option(option, output = nil)
return unless option
return output if output
option
end

def markdown(text)
return unless text
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(text).html_safe
end

def markdown_help_url
"http://nestacms.com/docs/creating-content/markdown-cheat-sheet"
end
end
```
#### Views
Create a view at `app/views/pages/page.html.slim` that contains the following:
```ruby
Expand Down
18 changes: 18 additions & 0 deletions app/helpers/component_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module ComponentHelper
def add_option(option, output = nil)
(output) ? output : option if option
end

def markdown(text)
return unless text
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(text).html_safe
end

def markdown_help_url
"http://nestacms.com/docs/creating-content/markdown-cheat-sheet"
end

def render_children(children)
children.map(&:render).reduce(:+)
end
end
9 changes: 8 additions & 1 deletion lib/atomic_cms/engine.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module AtomicCms
require 'paperclip'
require 'pry'
class Engine < ::Rails::Engine
isolate_namespace AtomicCms

config.generators do |g|
g.test_framework :rspec, fixture: false
g.test_framework :rspec, fixture: false
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.assets false
g.helper false
end

initializer 'atomic_cms.action_controller' do |_app|
ActiveSupport.on_load :action_controller do
helper AtomicCms::ComponentHelper
end
end
end
end

0 comments on commit f9bb59d

Please sign in to comment.