Skip to content

Instantly share code, notes, and snippets.

@stevehanson
Last active February 22, 2019 21:54
Show Gist options
  • Save stevehanson/1551ade88fc260081e52 to your computer and use it in GitHub Desktop.
Save stevehanson/1551ade88fc260081e52 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
@delusioninabox
Copy link

Thank you for this! 🙌 Quick and easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment