Skip to content
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

Added Handlebars preview #136

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `preview`
- [x] [Literate CoffeeScript](https://github.com/Glavin001/atom-preview/pull/18)
- [x] [LESS](https://github.com/Glavin001/atom-preview/issues/2)
- [x] [Jade](https://github.com/Glavin001/atom-preview/issues/8)
- [x] [Handlebars](https://github.com/Glavin001/atom-preview/issues/35)
- [x] [DogeScript](https://github.com/Glavin001/atom-preview/issues/12)
- [x] [TypeScript](https://github.com/Glavin001/atom-preview/issues/5)
- [x] [Stylus](https://github.com/Glavin001/atom-preview/issues/21)
Expand Down
9 changes: 9 additions & 0 deletions lib/renderer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ module.exports =
cb null, result
lang: -> 'html'
exts: /\.(pug)$/i
'Handlebars':
render: (text, filepath, cb) ->
Handlebars = allowUnsafeNewFunction -> allowUnsafeEval -> require 'handlebars'
template = allowUnsafeNewFunction -> allowUnsafeEval ->
Handlebars.compile text
Copy link
Collaborator

@nemoDreamer nemoDreamer Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaliy I searched the Handlebars API and can't find whether compile would throw on faulty syntax. Is this a case you need to account for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaliy are you still interested in looking into this?

result = allowUnsafeNewFunction -> allowUnsafeEval -> template {}
cb null, result
lang: -> 'html'
exts: /\.(handlebars)$/i
'Dogescript':
render: (text, filepath, cb) ->
dogescript = require "dogescript"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"dogeon": "^1.0.0",
"dogescript": "^2.3.0",
"ember-script": "0.0.14",
"handlebars": "^4.0.6",
"jade": "^1.4.2",
"js-yaml": "^3.6.0",
"less": "^2.6.1",
Expand Down