Nkss: Helpers |
|
A bunch of helpers you can use in your styleguides. |
module StyleguideHelper |
kss_block |
|
Documents a styleguide block. Some options you can specify:
Example:
Example with options: |
def kss_block(section_id, options={}, &block)
section = @styleguide.section(section_id)
raise "Section '#{section_id}' not found." unless section.filename
example_html = capture(&block)
defaults = { background: 'light', align: 'left', code: 'true' }
options = defaults.merge(options)
bg = "bg-#{options[:background]}"
align = "align-#{options[:align]}"
classes = [bg, align]
render \
partial: 'styleguides/block',
locals: {
canvas_class: classes.join(' '),
code_block: block,
html: example_html,
show_code: options[:code],
section: section,
modifiers: (section.modifiers rescue Array.new),
options: options,
}
end |
kss_specimen |
|
Renders a type specimen. This is great for demoing fonts. Use it like so:
This gets you a |
def kss_specimen
render partial: 'styleguides/specimen'
end |
lorem |
|
Convenient lorem ipsum helper. Yeah, well, you'll need this for a lot of styleguide sections. Use it like so: |
def lorem
require 'ffaker'
Faker::Lorem
end |
markdown |
|
Markdownify some text. |
def markdown(text)
require 'bluecloth'
str = BlueCloth.new(text).to_html
str = str.html_safe if str.respond_to?(:html_safe)
str
end
end
|