Commit 4b98e236c15975a01d5efa9a10d7da76d0cb91c3

Authored by Braulio Bhavamitra
Committed by Victor Costa
1 parent a150d075

Add slim: fatest and prettiest templates for rails

Showing 3 changed files with 40 additions and 3 deletions   Show diff stats
Gemfile
... ... @@ -30,6 +30,7 @@ gem 'locale', '~> 2.1'
30 30 gem 'whenever', :require => false
31 31 gem 'eita-jrails', '~> 0.10.0', require: 'jrails'
32 32 gem 'diffy', '~> 3.0'
  33 +gem 'slim'
33 34  
34 35 # API dependencies
35 36 gem 'grape', '~> 0.12'
... ... @@ -60,9 +61,6 @@ group :production do
60 61 gem 'dalli', '~> 2.7.0'
61 62 end
62 63  
63   -group :development do
64   -end
65   -
66 64 group :development, :test do
67 65 gem 'spring'
68 66 end
... ...
debian/control
... ... @@ -80,6 +80,7 @@ Depends: adduser,
80 80 ruby-uglifier,
81 81 ruby-whenever,
82 82 ruby-will-paginate (>> 3.0.5-1),
  83 + ruby-slim,
83 84 tango-icon-theme,
84 85 unicorn (>= 4.8),
85 86 ${misc:Depends}
... ...
script/erb2slim 0 → 100755
... ... @@ -0,0 +1,38 @@
  1 +#!/usr/bin/env ruby
  2 +
  3 +require 'html2haml'
  4 +require 'haml2slim'
  5 +
  6 +def run cmd
  7 + puts cmd
  8 + system cmd
  9 +end
  10 +
  11 +def convert erb
  12 + run <<-CMD
  13 + html2haml --erb #{erb} | haml2slim | sed 's/ *\\\\$//g' > $(echo #{erb} | sed 's/erb/slim/') && rm #{erb}
  14 + CMD
  15 +end
  16 +
  17 +erb = ARGV[0]
  18 +if erb and not erb.empty?
  19 + if File.file? erb
  20 + convert erb
  21 + else
  22 + STDERR.puts "file '#{erb}' not found"
  23 + end
  24 +else
  25 + GLOB_ALL = '**/*.erb'
  26 + GLOB_HTML = '**/*.html.erb'
  27 + GLOB = GLOB_HTML
  28 +
  29 + Dir.glob(GLOB).each do |erb|
  30 + if File.file? erb
  31 + convert erb
  32 + elsif File.symlink? erb
  33 + run <<-CMD
  34 + mv #{erb} $(echo #{erb} | sed 's/erb/slim/')
  35 + CMD
  36 + end
  37 + end
  38 +end
... ...