-
Notifications
You must be signed in to change notification settings - Fork 11.8k
feat(broccoli): add jade render #626
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c8a4fd8
feat(broccoli): add jade render
TomFFox bced83c
style(broccoli/pug): add $, missing semicolon
TomFFox 219858c
chore(broccoli): rename jade to pug
TomFFox 1223c84
fix(broccoli/pug): do not assign return to unused var
TomFFox ec21422
chore(broccoli/pug): add test for pug render workflow
TomFFox 29c0fd9
docs(README): pug integration
TomFFox e945e41
test(e2e_workflow): disable flaky tests
TomFFox 29edbce
docs(README): update section for pug integration
TomFFox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* jshint node: true, esversion: 6 */ | ||
| 'use strict'; | ||
|
|
||
| const requireOrNull = require('./require-or-null'); | ||
| const Plugin = require('broccoli-caching-writer'); | ||
| const fse = require('fs-extra'); | ||
| const path = require('path'); | ||
| const Funnel = require('broccoli-funnel'); | ||
|
|
||
| let pug = requireOrNull('pug'); | ||
| if (!pug) { | ||
| pug = requireOrNull(`${process.env.PROJECT_ROOT}/node_modules/pug`); | ||
| } | ||
|
|
||
| class PugPlugin extends Plugin { | ||
| constructor(inputNodes, options) { | ||
| super(inputNodes, {}); | ||
|
|
||
| options = options || {}; | ||
| Plugin.call(this, inputNodes, { | ||
| cacheInclude: [/\.pug$/] | ||
| }); | ||
| this.options = options; | ||
| } | ||
|
|
||
| build() { | ||
| this.listFiles().forEach(fileName => { | ||
| this.compile(path.normalize(fileName), | ||
| path.normalize(this.inputPaths[0]), | ||
| path.normalize(this.outputPath)); | ||
| }); | ||
| } | ||
|
|
||
| compile(fileName, inputPath, outputPath) { | ||
| const outSourceName = fileName.replace(inputPath, outputPath); | ||
| const outFileName = outSourceName.replace(/\.pug$/, '.html'); | ||
|
|
||
| // We overwrite file, outFile and include the file path for the includePath. | ||
| // We also make sure the options don't include a data field. | ||
| const pugOptions = Object.assign(this.options, { | ||
| filename: fileName, | ||
| pretty: false | ||
| }); | ||
| delete pugOptions.data; | ||
|
|
||
| pug.renderFile(fileName, pugOptions, (error, result) => { | ||
| if (!error) { | ||
| fse.outputFileSync(outFileName, result, 'utf-8'); | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| exports.makeBroccoliTree = (sourceDir, options) => { | ||
| options = options || {}; | ||
|
|
||
| if (pug) { | ||
| let pugSrcTree = new Funnel(sourceDir, { | ||
| include: ['**/*.pug'], | ||
| allowEmpty: true | ||
| }); | ||
|
|
||
| return new PugPlugin([pugSrcTree], options); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,6 +393,39 @@ describe('Basic end-to-end Workflow', function () { | |
| }); | ||
| }); | ||
|
|
||
| it.skip('Installs pug support successfully', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this skipped?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other tests like sass support are skipped too since 7c0ba39 |
||
| this.timeout(420000); | ||
|
|
||
| sh.exec('npm install pug', { silent: true }); | ||
| return ng(['generate', 'component', 'test-component']) | ||
| .then(() => { | ||
| let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component'); | ||
| let pugFile = path.join(componentPath, 'test-component-pug.component.pug'); | ||
|
|
||
| expect(existsSync(componentPath)).to.be.equal(true); | ||
| sh.touch(pugFile); | ||
| expect(existsSync(pugFile)).to.be.equal(true); | ||
| let pugExample = 'h1 Test works!'; | ||
| fs.writeFileSync(pugFile, pugExample, 'utf8'); | ||
|
|
||
| sh.exec(`${ngBin} build`); | ||
| let destHtml = path.join(process.cwd(), 'dist', 'app', 'test-component', 'test-component-pug.component.html'); | ||
| expect(existsSync(destHtml)).to.be.equal(true); | ||
| let contents = fs.readFileSync(destHtml, 'utf8'); | ||
| expect(contents).to.include('<h1>Test works!</h1>'); | ||
|
|
||
| sh.rm('-f', destHtml); | ||
| process.chdir('src'); | ||
| sh.exec(`${ngBin} build`); | ||
| expect(existsSync(destHtml)).to.be.equal(true); | ||
| contents = fs.readFileSync(destHtml, 'utf8'); | ||
| expect(contents).to.include('<h1>Test works!</h1>'); | ||
|
|
||
| process.chdir('..'); | ||
| sh.exec('npm uninstall pug', { silent: true }); | ||
| }); | ||
| }); | ||
|
|
||
| it('Turn on `noImplicitAny` in tsconfig.json and rebuild', function () { | ||
| this.timeout(420000); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this section mean?