livingstyleguide 2.0.0.alpha.10 → 2.0.0.alpha.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/bin/livingstyleguide +5 -6
  3. data/lib/livingstyleguide.rb +18 -12
  4. data/lib/livingstyleguide/command_line_interface.rb +5 -6
  5. data/lib/livingstyleguide/commands.rb +39 -0
  6. data/lib/livingstyleguide/commands/add_wrapper_class.rb +4 -0
  7. data/lib/livingstyleguide/commands/coffee_script.rb +5 -0
  8. data/lib/livingstyleguide/{filters → commands}/colors.rb +1 -1
  9. data/lib/livingstyleguide/{filters → commands}/css.rb +1 -1
  10. data/lib/livingstyleguide/{filters → commands}/data.rb +1 -1
  11. data/lib/livingstyleguide/{filters → commands}/default.rb +1 -1
  12. data/lib/livingstyleguide/{filters → commands}/font_example.rb +2 -2
  13. data/lib/livingstyleguide/commands/full_width.rb +4 -0
  14. data/lib/livingstyleguide/commands/haml.rb +4 -0
  15. data/lib/livingstyleguide/{filters → commands}/import_and_use.rb +5 -5
  16. data/lib/livingstyleguide/{filters → commands}/javascript.rb +1 -1
  17. data/lib/livingstyleguide/{filters → commands}/layout.rb +4 -4
  18. data/lib/livingstyleguide/commands/markdown.rb +4 -0
  19. data/lib/livingstyleguide/{filters → commands}/options.rb +3 -3
  20. data/lib/livingstyleguide/commands/require.rb +4 -0
  21. data/lib/livingstyleguide/{filters → commands}/sass.rb +4 -2
  22. data/lib/livingstyleguide/commands/search_box.rb +10 -0
  23. data/lib/livingstyleguide/{filters → commands}/style.rb +1 -1
  24. data/lib/livingstyleguide/commands/syntax.rb +4 -0
  25. data/lib/livingstyleguide/commands/toggle_code.rb +4 -0
  26. data/lib/livingstyleguide/commands/type.rb +4 -0
  27. data/lib/livingstyleguide/document.rb +29 -26
  28. data/lib/livingstyleguide/integration.rb +4 -4
  29. data/lib/livingstyleguide/integration/compass.rb +2 -3
  30. data/lib/livingstyleguide/integration/rails.rb +3 -6
  31. data/lib/livingstyleguide/integration/sass.rb +1 -1
  32. data/lib/livingstyleguide/integration/sprockets.rb +2 -3
  33. data/lib/livingstyleguide/markdown_extensions.rb +9 -9
  34. data/lib/livingstyleguide/templates/code.html.erb +1 -1
  35. data/lib/livingstyleguide/templates/example.html.erb +1 -1
  36. data/lib/livingstyleguide/templates/javascript.html.erb +1 -1
  37. data/lib/livingstyleguide/templates/layout.html.erb +13 -1
  38. data/lib/livingstyleguide/templates/scripts/copy.js.erb +24 -0
  39. data/lib/livingstyleguide/templates/scripts/copy_code.js.erb +19 -0
  40. data/lib/livingstyleguide/templates/scripts/copy_colors.js.erb +36 -0
  41. data/lib/livingstyleguide/templates/scripts/search.js.erb +66 -0
  42. data/lib/livingstyleguide/templates/scripts/toggle_code.js.erb +53 -0
  43. data/lib/livingstyleguide/templates/search-box.html.erb +1 -68
  44. data/lib/livingstyleguide/templates/toggle-code.html.erb +1 -0
  45. data/lib/livingstyleguide/version.rb +1 -1
  46. data/stylesheets/_livingstyleguide.scss +6 -3
  47. data/stylesheets/livingstyleguide/_before.scss +10 -0
  48. data/stylesheets/livingstyleguide/_code.scss +4 -7
  49. data/stylesheets/livingstyleguide/_color-swatches.scss +15 -16
  50. data/stylesheets/livingstyleguide/_content.scss +5 -5
  51. data/stylesheets/livingstyleguide/_layout.scss +4 -3
  52. data/stylesheets/livingstyleguide/_reset.scss +2 -1
  53. data/stylesheets/livingstyleguide/_toggle-code.scss +21 -0
  54. data/stylesheets/livingstyleguide/_variables.scss +5 -1
  55. metadata +46 -29
  56. data/assets/javascripts/livingstyleguide.js +0 -75
  57. data/lib/livingstyleguide/engine.rb +0 -194
  58. data/lib/livingstyleguide/filters.rb +0 -38
  59. data/lib/livingstyleguide/filters/add_wrapper_class.rb +0 -4
  60. data/lib/livingstyleguide/filters/coffee_script.rb +0 -5
  61. data/lib/livingstyleguide/filters/full_width.rb +0 -4
  62. data/lib/livingstyleguide/filters/haml.rb +0 -4
  63. data/lib/livingstyleguide/filters/markdown.rb +0 -4
  64. data/lib/livingstyleguide/filters/require.rb +0 -4
  65. data/lib/livingstyleguide/filters/search_box.rb +0 -9
  66. data/lib/livingstyleguide/filters/syntax.rb +0 -4
  67. data/lib/livingstyleguide/filters/type.rb +0 -4
  68. data/lib/livingstyleguide/templates/code-example.html.erb +0 -21
  69. data/lib/livingstyleguide/templates/colors-example.html.erb +0 -38
  70. data/lib/livingstyleguide/templates/javascript-copy.html.erb +0 -26
  71. data/stylesheets/livingstyleguide/_search.scss +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba96e42a926901d8cd5997497cec4602f05f179c
4
- data.tar.gz: b2e505615ea2fdcb6e5d6112bc8fe1d4c69b41ca
3
+ metadata.gz: ac71c904b754f1bf069310514347b950d2d0ab8d
4
+ data.tar.gz: 37b597563643b5db04e73fb181f8be5b23917ada
5
5
  SHA512:
6
- metadata.gz: 8f9fac2110874728aad315e163252dec08023263415490220151b45ac208a53ab5ac2d7a9c1b390ff6f734789ed568460e75bb8c9cbb48f7ece2eb649fa1247c
7
- data.tar.gz: d3f407cef912bb92a79cf0f80ffe98a7ddb75ee5b740e28a241550f813f968cc0999d1ca6ba7d296abdddffd9e45745952c9d3d61be5f67a883957f2e7bc546f
6
+ metadata.gz: bea2424d954964fd4c77f113ba255858efb06479f961089580c00617add66e69960b3b3599c53400587a6f0a0f3e4c947086ab118d6c344f88d71efb4d52c1f0
7
+ data.tar.gz: 6c051d0f26ef17995e7f1ebeef29ef520d937136b93976107351fda9f8e8a8f0f83d0e6a51d802a9cbfd616dd3bc8b776726f7ca0e26f9182b4f1ae1e05dfb01
data/bin/livingstyleguide CHANGED
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
3
+ require "rubygems"
4
4
  begin
5
- require 'bundler/setup'
5
+ require "bundler/setup"
6
6
  rescue LoadError
7
7
  end
8
8
 
9
- lib = File.expand_path('../lib', File.dirname(__FILE__))
9
+ lib = File.expand_path("../lib", File.dirname(__FILE__))
10
10
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
11
11
 
12
- require 'livingstyleguide'
13
- require 'livingstyleguide/command_line_interface'
12
+ require "livingstyleguide"
13
+ require "livingstyleguide/command_line_interface"
14
14
 
15
15
  LivingStyleGuide::CommandLineInterface.start(ARGV)
16
-
@@ -4,25 +4,25 @@ Encoding.default_internal = Encoding::UTF_8
4
4
  require "yaml"
5
5
 
6
6
  begin
7
- require 'compass'
7
+ require "compass"
8
8
  rescue LoadError
9
9
  end
10
10
 
11
11
  module LivingStyleGuide
12
12
  @@default_options = {
13
13
  default_language: :example,
14
- title: 'Living Style Guide',
15
- header: '<h1 class="lsg--page-title">Living Style Guide</h1>',
16
- footer: '<div class="lsg--footer"><a class="lsg--logo" href="http://livingstyleguide.org">Made with the LivingStyleGuide gem.</a></div>',
17
- root: '/'
14
+ title: "Living Style Guide",
15
+ header: %Q(<h1 class="lsg--page-title">Living Style Guide</h1>),
16
+ footer: %Q(<div class="lsg--footer"><a class="lsg--logo" href="http://livingstyleguide.org">Made with the LivingStyleGuide gem.</a></div>),
17
+ root: "/"
18
18
  }
19
19
 
20
20
  def self.default_options
21
21
  @@default_options
22
22
  end
23
23
 
24
- def self.add_filter(*keys, &block)
25
- Filters.add_filter(*keys, &block)
24
+ def self.command(*keys, &block)
25
+ Commands.command(*keys, &block)
26
26
  end
27
27
 
28
28
  def self.parse_data(data)
@@ -34,10 +34,16 @@ module LivingStyleGuide
34
34
  end
35
35
  end
36
36
  end
37
+
38
+ def self.template(file, scope)
39
+ file = "#{File.dirname(__FILE__)}/livingstyleguide/templates/#{file}"
40
+ erb = File.read(file)
41
+ ERB.new(erb).result(scope)
42
+ end
37
43
  end
38
44
 
39
- require 'livingstyleguide/version'
40
- require 'livingstyleguide/markdown_extensions'
41
- require 'livingstyleguide/document'
42
- require 'livingstyleguide/filters'
43
- require 'livingstyleguide/integration'
45
+ require "livingstyleguide/version"
46
+ require "livingstyleguide/markdown_extensions"
47
+ require "livingstyleguide/document"
48
+ require "livingstyleguide/commands"
49
+ require "livingstyleguide/integration"
@@ -1,10 +1,10 @@
1
- require 'thor'
2
- require 'tilt'
1
+ require "thor"
2
+ require "tilt"
3
3
 
4
4
  module LivingStyleGuide
5
5
  class CommandLineInterface < Thor
6
6
 
7
- desc 'compile input_file output_file', 'Compiles the living style guide to HTML.'
7
+ desc "compile input_file output_file", "Compiles the living style guide to HTML."
8
8
  def compile(input_file = nil, output_file = nil)
9
9
  doc = LivingStyleGuide::Document.new(input_file) do
10
10
  input(input_file)
@@ -12,7 +12,7 @@ module LivingStyleGuide
12
12
  output doc.render, input_file, output_file
13
13
  end
14
14
 
15
- desc 'version', 'Shows the current version of the Gem'
15
+ desc "version", "Shows the current version of the Gem"
16
16
  def version
17
17
  puts "LivingStyleGuide #{LivingStyleGuide::VERSION}"
18
18
  end
@@ -31,7 +31,7 @@ module LivingStyleGuide
31
31
  if input_file.nil?
32
32
  puts html
33
33
  else
34
- output_file = input_file.sub(/(\.html)?\.lsg$/, '.html') if output_file.nil?
34
+ output_file = input_file.sub(/(\.html)?\.lsg$/, ".html") if output_file.nil?
35
35
  if defined?(Compass)
36
36
  Compass.add_project_configuration
37
37
  output_file = output_file.sub(/^#{Compass.configuration.sass_dir}/, Compass.configuration.css_dir)
@@ -43,4 +43,3 @@ module LivingStyleGuide
43
43
 
44
44
  end
45
45
  end
46
-
@@ -0,0 +1,39 @@
1
+ class LivingStyleGuide::Commands
2
+ attr_reader :document
3
+
4
+ def initialize(doc)
5
+ @document = doc
6
+ end
7
+
8
+ def get_binding
9
+ binding
10
+ end
11
+
12
+ def self.command(*keys, &block)
13
+ keys.each do |key|
14
+ define_method key, &block
15
+ end
16
+ end
17
+ end
18
+
19
+ require "livingstyleguide/commands/options"
20
+ require "livingstyleguide/commands/default"
21
+ require "livingstyleguide/commands/import_and_use"
22
+ require "livingstyleguide/commands/require"
23
+ require "livingstyleguide/commands/full_width"
24
+ require "livingstyleguide/commands/haml"
25
+ require "livingstyleguide/commands/type"
26
+ require "livingstyleguide/commands/markdown"
27
+ require "livingstyleguide/commands/javascript"
28
+ require "livingstyleguide/commands/coffee_script"
29
+ require "livingstyleguide/commands/add_wrapper_class"
30
+ require "livingstyleguide/commands/font_example"
31
+ require "livingstyleguide/commands/colors"
32
+ require "livingstyleguide/commands/css"
33
+ require "livingstyleguide/commands/sass"
34
+ require "livingstyleguide/commands/style"
35
+ require "livingstyleguide/commands/data"
36
+ require "livingstyleguide/commands/layout"
37
+ require "livingstyleguide/commands/syntax"
38
+ require "livingstyleguide/commands/search_box"
39
+ require "livingstyleguide/commands/toggle_code"
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :add_wrapper_class do |arguments, options, block|
2
+ document.classes << arguments.first
3
+ nil
4
+ end
@@ -0,0 +1,5 @@
1
+ LivingStyleGuide.command :coffee_script, :coffee do |arguments, options, block|
2
+ document.type = :coffee
3
+ document.template = :javascript
4
+ nil
5
+ end
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :colors do |arguments, options, content|
1
+ LivingStyleGuide.command :colors do |arguments, options, content|
2
2
  colors = content.split(/\n+/).map{ |l| l.strip.split(/\s+/) }
3
3
  columns = colors.map{ |l| l.size }.max
4
4
  colors = colors.flatten
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :css do |arguments, options, css|
1
+ LivingStyleGuide.command :css do |arguments, options, css|
2
2
  file = arguments.first
3
3
  if file =~ /\.css$/
4
4
  if document.file
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :data do |arguments, options, data|
1
+ LivingStyleGuide.command :data do |arguments, options, data|
2
2
  data = LivingStyleGuide.parse_data(data)
3
3
  if data.is_a?(Array)
4
4
  document.locals = [] unless document.locals.is_a?(Array)
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :default do |arguments, options, block|
1
+ LivingStyleGuide.command :default do |arguments, options, block|
2
2
  key = arguments.first ? arguments.first.gsub("-", "_").to_sym : :global
3
3
  document.defaults[key] ||= {}
4
4
  document.defaults[key].merge!(options)
@@ -5,11 +5,11 @@ LivingStyleGuide.default_options[:font_example] = { text: <<-TEXT }
5
5
  !&/()$=@;:,.
6
6
  TEXT
7
7
 
8
- LivingStyleGuide.add_filter :font_example do |arguments, options, text|
8
+ LivingStyleGuide.command :font_example do |arguments, options, text|
9
9
  text ||= LivingStyleGuide.default_options[:font_example][:text]
10
10
  text = ERB::Util.html_escape(text)
11
11
  text.strip!
12
12
  text.gsub!(/\n/, "<br>\n")
13
13
  font = ERB::Util.html_escape(arguments.first)
14
- ERB.new(File.read("#{File.dirname(__FILE__)}/../templates/font-example.html.erb")).result(binding)
14
+ LivingStyleGuide.template("font-example.html.erb", binding)
15
15
  end
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :full_width do |arguments, options, block|
2
+ document.classes << '-lsg-has-full-width'
3
+ nil
4
+ end
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :haml do |arguments, options, block|
2
+ document.type = :haml
3
+ nil
4
+ end
@@ -1,8 +1,8 @@
1
- require 'tilt'
1
+ require "tilt"
2
2
 
3
3
  def map_files(glob, &block)
4
- glob << '.lsg' unless glob =~ /\.(\w+|\*)$/
5
- glob.gsub!(/[^\/]+$/, '{_,}\\0')
4
+ glob << ".lsg" unless glob =~ /\.(\w+|\*)$/
5
+ glob.gsub!(/[^\/]+$/, "{_,}\\0")
6
6
  glob = File.join(document.path, glob)
7
7
 
8
8
  Dir.glob(glob).map do |file|
@@ -11,7 +11,7 @@ def map_files(glob, &block)
11
11
  end.join
12
12
  end
13
13
 
14
- LivingStyleGuide.add_filter :import do |arguments, options, data|
14
+ LivingStyleGuide.command :import do |arguments, options, data|
15
15
  glob = arguments.first
16
16
  if glob =~ /\.s[ac]ss$/
17
17
  raise "Error: Please use `@css #{glob}` instead of `@import #{glob}` for importing Sass."
@@ -26,7 +26,7 @@ LivingStyleGuide.add_filter :import do |arguments, options, data|
26
26
  end
27
27
  end
28
28
 
29
- LivingStyleGuide.add_filter :use do |arguments, options, data|
29
+ LivingStyleGuide.command :use do |arguments, options, data|
30
30
  glob = arguments.first
31
31
  map_files glob do |file|
32
32
  File.read(file)
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :javascript do |arguments, options, block|
1
+ LivingStyleGuide.command :javascript do |arguments, options, block|
2
2
  document.type = :javascript
3
3
  document.template = :javascript
4
4
  nil
@@ -1,11 +1,11 @@
1
- LivingStyleGuide.add_filter :title do |arguments, options, block|
1
+ LivingStyleGuide.command :title do |arguments, options, block|
2
2
  document.title = arguments.first
3
3
  nil
4
4
  end
5
5
 
6
6
  { :before => :head, :after => :footer }.each do |name, destination|
7
7
  eval <<-RUBY
8
- LivingStyleGuide.add_filter :javascript_#{name} do |arguments, options, block|
8
+ LivingStyleGuide.command :javascript_#{name} do |arguments, options, block|
9
9
  if src = arguments.first
10
10
  document.#{destination} << %Q(<script src="\#{src}"></script>)
11
11
  else
@@ -19,9 +19,9 @@ end
19
19
  RUBY
20
20
  end
21
21
 
22
- %w(head header footer).each do |part|
22
+ %w(head header footer before after).each do |part|
23
23
  eval <<-RUBY
24
- LivingStyleGuide.add_filter :#{part} do |arguments, options, block|
24
+ LivingStyleGuide.command :#{part} do |arguments, options, block|
25
25
  html = LivingStyleGuide::Document.new(livingstyleguide: document) { block }
26
26
  html.type = options[:type]
27
27
  document.#{part} << html.render + "\n"
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :markdown do |arguments, options, block|
2
+ document.type = :markdown
3
+ nil
4
+ end
@@ -1,9 +1,9 @@
1
- LivingStyleGuide.add_filter :set do |arguments, options, block|
1
+ LivingStyleGuide.command :set do |arguments, options, block|
2
2
  options.each do |key, value|
3
3
  document.options[key] = case value
4
- when 'true'
4
+ when "true"
5
5
  true
6
- when 'false'
6
+ when "false"
7
7
  false
8
8
  when /^\d+$/
9
9
  value.to_i
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :require do |arguments, options, block|
2
+ Kernel.require arguments.first
3
+ nil
4
+ end
@@ -1,4 +1,6 @@
1
- LivingStyleGuide.add_filter :scss do |arguments, options, scss|
1
+ require "sass"
2
+
3
+ LivingStyleGuide.command :scss do |arguments, options, scss|
2
4
  file = arguments.first
3
5
  if file
4
6
  if document.file
@@ -12,7 +14,7 @@ LivingStyleGuide.add_filter :scss do |arguments, options, scss|
12
14
  nil
13
15
  end
14
16
 
15
- LivingStyleGuide.add_filter :sass do |arguments, options, sass|
17
+ LivingStyleGuide.command :sass do |arguments, options, sass|
16
18
  file = arguments.first
17
19
  if file
18
20
  if document.file
@@ -0,0 +1,10 @@
1
+ LivingStyleGuide.default_options[:search_box] = {
2
+ placeholder: "Search …"
3
+ }
4
+
5
+ LivingStyleGuide.command :search_box do |arguments, options, content|
6
+ placeholder = options[:placeholder] || LivingStyleGuide.default_options[:search_box][:placeholder]
7
+ document.before << LivingStyleGuide.template("search-box.html.erb", binding)
8
+ document.javascript << LivingStyleGuide.template("scripts/search.js.erb", binding)
9
+ nil
10
+ end
@@ -1,4 +1,4 @@
1
- LivingStyleGuide.add_filter :style do |arguments, options, block|
1
+ LivingStyleGuide.command :style do |arguments, options, block|
2
2
  options.delete :block_type
3
3
  options.each do |key, value|
4
4
  document.scss << %Q($lsg--#{key.to_s.gsub("_", "-")}: #{value};\n)
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :syntax do |arguments, options, block|
2
+ document.syntax = arguments.first.to_sym
3
+ nil
4
+ end
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :toggle_code do |arguments, options, content|
2
+ document.before << LivingStyleGuide.template("toggle-code.html.erb", binding)
3
+ nil
4
+ end
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.command :type do |arguments, options, block|
2
+ document.type = arguments.first.to_sym
3
+ nil
4
+ end
@@ -1,18 +1,18 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'tilt'
4
- require 'erb'
5
- require 'digest'
6
- require 'pathname'
3
+ require "tilt"
4
+ require "erb"
5
+ require "digest"
6
+ require "pathname"
7
7
 
8
8
  class LivingStyleGuide::Document < ::Tilt::Template
9
- attr_accessor :source, :type, :filters, :template, :classes, :html
9
+ attr_accessor :source, :type, :commands, :template, :classes, :html
10
10
  attr_accessor :css, :id, :locals
11
11
  attr_accessor :title
12
12
  attr_accessor :syntax
13
13
  attr_reader :scope
14
14
 
15
- %w(scss head header footer defaults).each do |attr|
15
+ %w(scss head header footer defaults javascript before after).each do |attr|
16
16
  define_method attr do
17
17
  if options.has_key?(:livingstyleguide)
18
18
  options[:livingstyleguide].send(attr)
@@ -32,11 +32,11 @@ class LivingStyleGuide::Document < ::Tilt::Template
32
32
 
33
33
  def prepare
34
34
  @type = :lsg
35
- @filters = LivingStyleGuide::Filters.new(self)
35
+ @commands = LivingStyleGuide::Commands.new(self)
36
36
  @template = options.has_key?(:livingstyleguide) ? :default : :layout
37
37
  @classes = []
38
- @scss = ''
39
- @css = ''
38
+ @scss = ""
39
+ @css = ""
40
40
  @locals = {}
41
41
  @defaults = {
42
42
  global: {
@@ -58,7 +58,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
58
58
  end
59
59
 
60
60
  def css
61
- scss_with_lsg = "#{scss}; @import 'livingstyleguide';"
61
+ scss_with_lsg = %Q(#{scss}; @import "livingstyleguide";)
62
62
  render_scss(scss_with_lsg)
63
63
  end
64
64
 
@@ -77,7 +77,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
77
77
  end
78
78
 
79
79
  def erb
80
- @erb ||= parse_filters do |name, arguments, options, block|
80
+ @erb ||= parse_commands do |name, arguments, options, block|
81
81
  options = %Q(document.defaults[:global].merge(document.defaults[:@#{name}] || {}).merge(#{options.inspect}))
82
82
  "<%= #{name}(#{arguments.inspect}, #{options}, #{block.inspect}) %>\n"
83
83
  end
@@ -85,13 +85,16 @@ class LivingStyleGuide::Document < ::Tilt::Template
85
85
 
86
86
  def evaluate(scope, locals, &block)
87
87
  @head = ""
88
- @head << ERB.new(File.read("#{File.dirname(__FILE__)}/templates/javascript-copy.html.erb")).result(binding)
89
- @head << ERB.new(File.read("#{File.dirname(__FILE__)}/templates/code-example.html.erb")).result(binding)
90
- @head << ERB.new(File.read("#{File.dirname(__FILE__)}/templates/colors-example.html.erb")).result(binding)
88
+ @javascript = ""
89
+ %w(copy copy_code copy_colors toggle_code).each do |partial|
90
+ @javascript << LivingStyleGuide.template("scripts/#{partial}.js.erb", binding)
91
+ end
91
92
  @header = ""
93
+ @before = ""
94
+ @after = ""
92
95
  @footer = ""
93
96
  @scope = scope
94
- result = ERB.new(erb).result(@filters.get_binding)
97
+ result = ERB.new(erb).result(@commands.get_binding)
95
98
  @source = result
96
99
  @html = render_html(result, locals)
97
100
  @classes.unshift "lsg--#{@type}-example"
@@ -183,7 +186,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
183
186
 
184
187
  private
185
188
  def remove_highlights(code)
186
- code.gsub(/\*\*\*/, '')
189
+ code.gsub(/\*\*\*/, "")
187
190
  end
188
191
 
189
192
  private
@@ -192,18 +195,18 @@ class LivingStyleGuide::Document < ::Tilt::Template
192
195
  end
193
196
 
194
197
  private
195
- def parse_filters
196
- data.gsub('<%', '<%%').gsub(/\G(.*?)((```.+?```)|\Z)/m) do
198
+ def parse_commands
199
+ data.gsub("<%", "<%%").gsub(/\G(.*?)((```.+?```)|\Z)/m) do
197
200
  content, code_block = $1, $2
198
201
  content.gsub(/^@([\w\d_-]+)(?: ([^\n]*[^\{\n:]))?(?: *\{\n((?:.|\n)*?)\n\}|((?:\n+ .*)+(?=\n|\Z))| *:\n((?:.|\n)*?)(?:\n\n|\Z))?/) do
199
- name, arguments_string, block = $1, $2 || '', $3 || $4 || $5
202
+ name, arguments_string, block = $1, $2 || "", $3 || $4 || $5
200
203
  options = {
201
204
  block_type: $3 ? :braces : $4 ? :indented : $5 ? :block : :none
202
205
  }
203
- name = name.gsub('-', '_').to_sym
206
+ name = name.gsub("-", "_").to_sym
204
207
  arguments = parse_arguments(arguments_string, options)
205
208
  if options[:block_type] == :indented
206
- block.gsub!(/\A\n(\s*)((?:.|\n)+)\Z/){ $2.gsub(/^#{$1}/, '') }
209
+ block.gsub!(/\A\n(\s*)((?:.|\n)+)\Z/){ $2.gsub(/^#{$1}/, "") }
207
210
  end
208
211
  yield name, arguments, options, block
209
212
  end + code_block
@@ -217,7 +220,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
217
220
  argument.strip!
218
221
  argument.gsub! "\\;", ";"
219
222
  if /^(?<key>[a-zA-Z0-9_\-]+):(?<value>.+)$/ =~ argument
220
- options[key.downcase.gsub('-', '_').to_sym] = remove_quots(value.strip)
223
+ options[key.downcase.gsub("-", "_").to_sym] = remove_quots(value.strip)
221
224
  nil
222
225
  else
223
226
  remove_quots(argument)
@@ -228,7 +231,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
228
231
 
229
232
  private
230
233
  def remove_quots(string)
231
- string.sub(/^"(.*)"$|^'(.*)'$|^(.*)$/, '\\1\\2\\3').gsub(/\\("|')/, "\\1")
234
+ string.sub(/^"(.*)"$|^"(.*)"$|^(.*)$/, "\\1\\2\\3").gsub(/\\("|")/, "\\1")
232
235
  end
233
236
 
234
237
  private
@@ -252,7 +255,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
252
255
  def generate_id
253
256
  if @file
254
257
  id = Pathname.new(@file).cleanpath.to_s
255
- id.sub('/_', '/').gsub(/\.\w+/, '')
258
+ id.sub("/_", "/").gsub(/\.\w+/, "")
256
259
  else
257
260
  "section-#{Digest::SHA256.hexdigest(data)[0...6]}"
258
261
  end
@@ -260,7 +263,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
260
263
 
261
264
  private
262
265
  def scss_template
263
- ::LivingStyleGuide.default_options[:scss_template] || Tilt['scss']
266
+ ::LivingStyleGuide.default_options[:scss_template] || Tilt["scss"]
264
267
  end
265
268
 
266
269
  private
@@ -277,4 +280,4 @@ class LivingStyleGuide::Document < ::Tilt::Template
277
280
  end
278
281
  end
279
282
 
280
- Tilt.register 'lsg', LivingStyleGuide::Document
283
+ Tilt.register "lsg", LivingStyleGuide::Document