Last active
October 12, 2017 22:40
-
-
Save bholtbholt/69d5f31a1642dd6be822c00088b0eeda to your computer and use it in GitHub Desktop.
Ruby on Rails server-side component library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def prefix_component(component, options = {}) | |
render partial: "components/#{component}", locals: { options: options } | |
rescue ActionView::MissingTemplate | |
render partial: "components/help", locals: { component: component } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe 'Component documentation' do | |
it 'should exist for all components' do | |
Dir.foreach("#{Rails.root}/app/views/components/") do |file| | |
next unless file.start_with?("_") | |
documentation_file = File.file?("#{Rails.root}/app/views/components/documentation/#{file}") | |
expect(documentation_file).to be(true), "#{file} doesn't exist in components/documentation" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= prefix_component(:academy_banner, | |
id: "academy-banner-id", | |
title: "This is the Academy Banner", | |
text: "This is supporting text" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment