Skip to content

Commit

Permalink
Closes #80. Add HTML Embedded Ruby (ERB) support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Sep 8, 2014
1 parent d595ea7 commit 6652e7f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`

- [x] JavaScript and JSON
- [x] HTML, including
- [Handlebars](http://handlebarsjs.com/)
- XML
- [x] [Handlebars](http://handlebarsjs.com/)
- [x] [Embedded Ruby (ERB)](https://github.com/Glavin001/atom-beautify/issues/80)
- Requires [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier)
- [x] XML
- [x] CSS, including
- [Sass](http://sass-lang.com/)
- [LESS](http://lesscss.org/)
Expand Down
18 changes: 18 additions & 0 deletions examples/simple-jsbeautifyrc/test.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></title>
</head>
<body>
<h1>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></h1>
<p>You need to buy:</p>
<ul>
<% for @item in @items %>
<li><%= h(@item) %></li>
<% end %>
</ul>
</body>
</html>
9 changes: 9 additions & 0 deletions lib/langs/html-erb-beautify.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###
Requires https://github.com/hhatto/autopep8
###
"use strict"
cliBeautify = require("./cli-beautify")
getCmd = (inputPath, outputPath, options) ->
# Use command available in $PATH
"htmlbeautifier < \"" + inputPath + "\" > \"" + outputPath + "\""
module.exports = cliBeautify(getCmd)
4 changes: 4 additions & 0 deletions lib/language-options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ beautifyRuby = null
beautifyLESS = null
beautifyCoffeeScript = null
uncrustifyBeautifier = null
beautifyHTMLERB = null

# Misc
Analytics = require("analytics-node")
Expand Down Expand Up @@ -149,6 +150,9 @@ module.exports =
beautifyHTML ?= require("js-beautify").html
text = beautifyHTML(text, self.getOptions("html", allOptions))
beautifyCompleted text
when "HTML (Ruby - ERB)"
beautifyHTMLERB ?= require("./langs/html-erb-beautify")
beautifyHTMLERB text, self.getOptions("html", allOptions), beautifyCompleted
when "CSS"
beautifyCSS ?= require("js-beautify").css
text = beautifyCSS(text, self.getOptions("css", allOptions))
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"java",
"pawn",
"vala",
"d"
"d",
"erb"
],
"engines": {
"atom": ">0.50.0"
Expand Down

0 comments on commit 6652e7f

Please sign in to comment.