Skip to content

Handlebars fixes #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Web Compiler

A Visual Studio extension that compiles LESS, Sass Stylus, JSX, ES6 and CoffeeScript
A Visual Studio extension that compiles LESS, Sass Stylus, JSX, ES6, CoffeeScript and Handlebars
files.

[![Build status](https://ci.appveyor.com/api/projects/status/kyk8vpst641r2n0r?svg=true)](https://ci.appveyor.com/project/madskristensen/webcompiler)
Expand All @@ -16,7 +16,7 @@ for changes and roadmap.

### Features

- Compilation of LESS, Scss, Stylus, JSX, ES6 and (Iced)CoffeeScript files
- Compilation of LESS, Scss, Stylus, JSX, ES6, (Iced)CoffeeScript and HBS (Handlebars) files
- Saving a source file triggers re-compilation automatically
- Specify compiler options for each individual file
- Error List integration
Expand All @@ -31,7 +31,7 @@ for changes and roadmap.

### Getting started

Right-click any `.less`, `.scss`, `.styl`, `.jsx`, `.es6` or `.coffee` file in Solution Explorer to
Right-click any `.less`, `.scss`, `.styl`, `.jsx`, `.es6`, `.coffee` or `.hbs` file in Solution Explorer to
setup compilation.

![Compile file](art/contextmenu-compile.png)
Expand All @@ -46,7 +46,7 @@ run all the configured compilers.

### Compile on save

Any time a `.less`, `.scss`, `.styl`, `.jsx`, `.es6` or `.coffee` file is modified within
Any time a `.less`, `.scss`, `.styl`, `.jsx`, `.es6`, `.coffee` or `.hbs` file is modified within
Visual Studio, the compiler runs automatically to produce the compiled output file.

The same is true when saving the `compilerconfig.json` file where
Expand Down
9 changes: 4 additions & 5 deletions src/WebCompiler/Compile/HandlebarsOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using System.Linq;

namespace WebCompiler
{
Expand Down Expand Up @@ -54,16 +53,16 @@ protected override void LoadSettings(Config config)
KnownHelpersOnly = knownHelpersOnly.ToLowerInvariant() == trueStr;

var knownHelpers = GetValue(config, "knownHelpers");
if (knownHelpers != null)
KnownHelpers = knownHelpers.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToArray();
if (knownHelpers != null)
KnownHelpers = JsonConvert.DeserializeObject<string[]>(knownHelpers);
}

/// <summary>
/// The file name should match the compiler name
/// </summary>
protected override string CompilerFileName
{
get { return "hbs"; }
get { return "handlebars"; }
}

/// <summary>
Expand All @@ -85,7 +84,7 @@ protected override string CompilerFileName
public string Name { get; set; } = "";

/// <summary>
/// Template namespace
/// Template namespace
/// </summary>
[JsonProperty("namespace")]
public string TemplateNameSpace { get; set; } = "";
Expand Down
9 changes: 6 additions & 3 deletions src/WebCompilerVsix/JSON/compilerdefaults-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
}
}
},

"handlebars": {
"description": "Specify options for the compiler.",
"type": "object",
Expand All @@ -182,8 +182,11 @@
},
"knownHelpers": {
"description": "List of known helpers for a more optimized output (comma separated)",
"type": "string",
"default": ""
"type": "array",
"default": [],
"items": {
"type": "string"
}
},
"knownHelpersOnly": {
"description": "Compile with known helpers only",
Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Copyright>Copyright 2017</Copyright>
<Authors>Mads Kristensen</Authors>
<Description>Compiles LESS, Sass, JSX and CoffeeScript files</Description>
<Description>Compiles LESS, Sass, JSX, CoffeeScript and Handlebars files</Description>
<PackageTags>LESS;Sass;Scss;JSX;EcmaScript6;CoffeeScript</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/madskristensen/WebCompiler/master/src/WebCompilerVsix/Resources/icon.png</PackageIconUrl>
<PackageLicenseUrl>https://github.com/madskristensen/WebCompiler/blob/master/LICENSE</PackageLicenseUrl>
Expand Down