Merge pull request #2087 from darron1217/blade

Basic Implement of Blade Template
This commit is contained in:
Glavin Wiechert 2018-05-08 12:33:03 -03:00 committed by GitHub
commit 7b3bc35048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1283 additions and 368 deletions

View File

@ -67,12 +67,10 @@ before_install:
curl https://nixos.org/nix/install | sh &&
. ~/.nix-profile/etc/profile.d/nix.sh &&
nix-env -i uncrustify R elm-format terraform atom atom-beta opam &&
pip install --upgrade pip &&
pip install --user -r requirements.txt;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update && brew cask zap oclint && brew bundle &&
ln -s /usr/local/bin/elm-format-0.17 /usr/local/bin/elm-format &&
pip2 install --upgrade pip &&
pip2 install -r requirements.txt;
else
echo Error:TRAVIS_OS_NAME && exit 1;

View File

@ -1,5 +1,5 @@
# Next
- ...
- Issue [#448](https://github.com/Glavin001/atom-beautify/issues/448) Add support for Laravel Blade templates (beta)
# v0.32.2 (2018-03-10)
- Revert fix package.json repository field (#2062)

View File

@ -153,6 +153,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| Apex | `Apex` |`.cls`, `.trigger` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** |
| Arduino | `Arduino` |`.ino`, `.pde` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** |
| Bash | `Shell Script` |`.bash`, `.sh` | **[`beautysh`](https://github.com/bemeurer/beautysh)** |
| Blade | `Blade` |`.blade.php` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)** |
| C | `C`, `opencl` |`.h`, `.c`, `.cl` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)**, [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| Coldfusion | `html` |`.cfm`, `.cfml`, `.cfc` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Clojure | `Clojure` |`.clj`, `.cljs`, `.edn` | **[`cljfmt`](https://github.com/snoe/node-cljfmt)** |

View File

@ -8,3 +8,4 @@ language-elm
language-puppet
fuse
react
language-blade

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar') This is the {{ $mater }} sidebar.
@show
<div class="container">
@yield('content')
</div>
@component('alert')
@slot('title') Forbidden
@endslot
<strong>Whoops!</strong> Something went wrong!
@endcomponent
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach
</body>
</html>

View File

@ -0,0 +1,31 @@
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the {{ $mater }} sidebar.
@show
<div class="container">
@yield('content')
</div>
@component('alert')
@slot('title')
Forbidden
@endslot
<strong>Whoops!</strong> Something went wrong!
@endcomponent
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach
</body>
</html>

View File

@ -303,7 +303,8 @@
"atom-beautify:beautify-language-tsx",
"atom-beautify:beautify-language-verilog",
"atom-beautify:beautify-language-vhdl",
"atom-beautify:beautify-language-gn"
"atom-beautify:beautify-language-gn",
"atom-beautify:beautify-language-blade"
],
".tree-view .file .name": [
"atom-beautify:beautify-file"
@ -447,7 +448,8 @@
"emacs verilog mode",
"vhdl",
"vhdl beautifier",
"gn"
"gn",
"blade"
],
"devDependencies": {
"codo": "^2.1.2",

View File

@ -44,7 +44,7 @@ describe "BeautifyLanguages", ->
# Activate all of the languages
allLanguages = [
"c", "clojure", "coffee-script", "css", "csharp", "d",
"blade", "c", "clojure", "coffee-script", "css", "csharp", "d",
"gfm", "go", "html", "html-swig", "java", "javascript",
"json", "less", "lua", "marko", "mustache", "objective-c",
"perl", "php", "python", "ruby", "sass", "sql",

View File

@ -6,6 +6,7 @@ module.exports = class JSBeautify extends Beautifier
link: "https://github.com/beautify-web/js-beautify"
options: {
Blade: true
HTML: true
XML: true
Handlebars: true
@ -51,6 +52,16 @@ module.exports = class JSBeautify extends Beautifier
beautifyCSS = require("js-beautify").css
text = beautifyCSS(text, options)
resolve text
when "Blade"
beautifyHTML = require("js-beautify").html
# pre script (Workaround)
text = text.replace(/\@(?!yield)([^\n\s]*)/ig, "<blade $1/>")
text = beautifyHTML(text, options)
# post script (Workaround)
text = text.replace(/<blade ([^\n]*)\/>/ig, "@$1")
text = text.replace(/\(\ \'/ig, "('")
@debug("Beautified HTML: #{text}")
resolve text
else
reject(new Error("Unknown language for JS Beautify: "+language))
catch err

View File

@ -0,0 +1,22 @@
module.exports = {
name: "Blade"
namespace: "blade"
fallback: ["html"]
###
Supported Grammars
###
grammars: [
"Blade"
]
###
Supported extensions
###
extensions: [
"blade.php"
]
options: []
}

View File

@ -15,6 +15,7 @@ module.exports = class Languages
"apex"
"arduino"
"bash"
"blade"
"c-sharp"
"c"
"clojure"

View File

@ -186,6 +186,327 @@
}
}
},
"blade": {
"title": "Blade",
"type": "object",
"description": "Options for language Blade",
"collapsed": true,
"beautifiers": [
"JS Beautify"
],
"grammars": [
"Blade"
],
"extensions": [
"blade.php"
],
"properties": {
"indent_inner_html": {
"type": "boolean",
"default": false,
"description": "Indent <head> and <body> sections. (Supported by JS Beautify)",
"title": "Indent inner html",
"beautifiers": [
"JS Beautify"
],
"key": "indent_inner_html",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"indent_size": {
"type": "integer",
"default": null,
"minimum": 0,
"description": "Indentation size/length (Supported by JS Beautify)",
"title": "Indent size",
"beautifiers": [
"JS Beautify"
],
"key": "indent_size",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"indent_char": {
"type": "string",
"default": null,
"description": "Indentation character (Supported by JS Beautify)",
"title": "Indent char",
"beautifiers": [
"JS Beautify"
],
"key": "indent_char",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"brace_style": {
"type": "string",
"default": "collapse",
"enum": [
"collapse",
"expand",
"end-expand",
"none"
],
"description": "[collapse|expand|end-expand|none] (Supported by JS Beautify)",
"title": "Brace style",
"beautifiers": [
"JS Beautify"
],
"key": "brace_style",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"indent_scripts": {
"type": "string",
"default": "normal",
"enum": [
"keep",
"separate",
"normal"
],
"description": "[keep|separate|normal] (Supported by JS Beautify)",
"title": "Indent scripts",
"beautifiers": [
"JS Beautify"
],
"key": "indent_scripts",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"wrap_line_length": {
"type": "integer",
"default": 250,
"description": "Maximum characters per line (0 disables) (Supported by JS Beautify)",
"title": "Wrap line length",
"beautifiers": [
"JS Beautify"
],
"key": "wrap_line_length",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"wrap_attributes": {
"type": "string",
"default": "auto",
"enum": [
"auto",
"force",
"force-aligned",
"force-expand-multiline"
],
"description": "Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify)",
"title": "Wrap attributes",
"beautifiers": [
"JS Beautify"
],
"key": "wrap_attributes",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"wrap_attributes_indent_size": {
"type": "integer",
"default": null,
"minimum": 0,
"description": "Indent wrapped attributes to after N characters (Supported by JS Beautify)",
"title": "Wrap attributes indent size",
"beautifiers": [
"JS Beautify"
],
"key": "wrap_attributes_indent_size",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"preserve_newlines": {
"type": "boolean",
"default": true,
"description": "Preserve line-breaks (Supported by JS Beautify)",
"title": "Preserve newlines",
"beautifiers": [
"JS Beautify"
],
"key": "preserve_newlines",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"max_preserve_newlines": {
"type": "integer",
"default": 10,
"description": "Number of line-breaks to be preserved in one chunk (Supported by JS Beautify)",
"title": "Max preserve newlines",
"beautifiers": [
"JS Beautify"
],
"key": "max_preserve_newlines",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"unformatted": {
"type": "array",
"default": [
"a",
"abbr",
"area",
"audio",
"b",
"bdi",
"bdo",
"br",
"button",
"canvas",
"cite",
"code",
"data",
"datalist",
"del",
"dfn",
"em",
"embed",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"keygen",
"label",
"map",
"mark",
"math",
"meter",
"noscript",
"object",
"output",
"progress",
"q",
"ruby",
"s",
"samp",
"select",
"small",
"span",
"strong",
"sub",
"sup",
"svg",
"template",
"textarea",
"time",
"u",
"var",
"video",
"wbr",
"text",
"acronym",
"address",
"big",
"dt",
"ins",
"small",
"strike",
"tt",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
],
"items": {
"type": "string"
},
"description": "List of tags (defaults to inline) that should not be reformatted (Supported by JS Beautify)",
"title": "Unformatted",
"beautifiers": [
"JS Beautify"
],
"key": "unformatted",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"end_with_newline": {
"type": "boolean",
"default": false,
"description": "End output with newline (Supported by JS Beautify)",
"title": "End with newline",
"beautifiers": [
"JS Beautify"
],
"key": "end_with_newline",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"extra_liners": {
"type": "array",
"default": [
"head",
"body",
"/html"
],
"items": {
"type": "string"
},
"description": "List of tags (defaults to [head,body,/html] that should have an extra newline before them. (Supported by JS Beautify)",
"title": "Extra liners",
"beautifiers": [
"JS Beautify"
],
"key": "extra_liners",
"language": {
"name": "HTML",
"namespace": "html"
}
},
"disabled": {
"title": "Disable Beautifying Language",
"order": -3,
"type": "boolean",
"default": false,
"description": "Disable Blade Beautification"
},
"default_beautifier": {
"title": "Default Beautifier",
"order": -2,
"type": "string",
"default": "JS Beautify",
"description": "Default Beautifier to be used for Blade",
"enum": [
"JS Beautify"
]
},
"beautify_on_save": {
"title": "Beautify On Save",
"order": -1,
"type": "boolean",
"default": false,
"description": "Automatically beautify Blade files on save"
}
}
},
"cs": {
"title": "C#",
"type": "object",