Skip to content

Instantly share code, notes, and snippets.

@salfedev
Forked from stevehanson/emblem_to_hbs.rb
Created April 27, 2018 11:23
Show Gist options
  • Save salfedev/976e25a7f24c0107796cf75f793d9623 to your computer and use it in GitHub Desktop.
Save salfedev/976e25a7f24c0107796cf75f793d9623 to your computer and use it in GitHub Desktop.
Convert all project Emblem files to handlebars

Convert Emblem to HBS

emblem2hbs, by patientslikeme, is an awesome utility that can convert single Emblem files to HBS. This script attached takes it a step farther and converts all emblem files in your project to HBS. Here is how to do it:

  1. Install emblem2hbs: npm install -g emblem2hbs
  2. Drop the emblem_to_hbs.rb file from this gist into the root directory of your project
  3. Run ruby emblem_to_hbs.rb. This will convert any .emblem files in your project to HBS
class EmblemToHbs
def convert
Dir.glob("**/*.emblem").each do |file|
convert_file(file)
end
end
def convert_file(file)
`emblem2hbs #{file}`
File.delete(file)
new_file_name = file.gsub(".emblem", ".js.hbs")
File.rename(new_file_name, new_file_name.gsub(".js.hbs", ".hbs"))
end
end
EmblemToHbs.new.convert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment