-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from opencomponents/es6-template
[DX-399] ES6 template
- Loading branch information
Showing
58 changed files
with
8,918 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 @@ | ||
mocks/es6-component/broken.js |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,30 @@ | ||
{ | ||
"name": "base-component-es6", | ||
"description": "", | ||
"version": "1.0.0", | ||
"private": true, | ||
"oc": { | ||
"files": { | ||
"data": "server.js", | ||
"static": [ | ||
"img" | ||
], | ||
"template": { | ||
"src": "view.js", | ||
"type": "oc-template-es6" | ||
} | ||
}, | ||
"parameters": { | ||
"name": { | ||
"default": "ES6 template", | ||
"description": "Your name", | ||
"example": "Jane Doe", | ||
"mandatory": false, | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"oc-template-es6-compiler": "file:../../packages/oc-template-es6-compiler" | ||
} | ||
} |
This file contains 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,9 @@ | ||
export const data = (context, callback) => { | ||
const { name } = context.params; | ||
const { staticPath } = context; | ||
|
||
callback(null, { | ||
name, | ||
staticPath | ||
}); | ||
}; |
This file contains 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,4 @@ | ||
.awesome { | ||
font-family: "Hiragino Sans", "ヒラギノ角ゴシック", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Roboto, "Droid Sans", "游ゴシック", YuGothic, "メイリオ", Meiryo, sans-serif; | ||
background: palevioletred; | ||
} |
This file contains 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,7 @@ | ||
import styles from './styles.css'; | ||
|
||
export default ({ name, staticPath }) => | ||
`<div id="base-component-es6" class=${styles.awesome}> | ||
Hello ${name.toUpperCase()}! | ||
<img src="${staticPath}img/logo.png" /> | ||
</div>`; |
Binary file modified
BIN
-2.22 KB
(93%)
acceptance-components/base-component-handlebars/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 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 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 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,2 @@ | ||
export default ({ name }) => | ||
<div>Hello ${name.toUpperCase()}!</div>`; |
This file contains 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,21 @@ | ||
{ | ||
"name": "es6-component", | ||
"description": "", | ||
"version": "1.0.0", | ||
"repository": "", | ||
"oc": { | ||
"files": { | ||
"data": "server.js", | ||
"template": { | ||
"src": "view.js", | ||
"type": "oc-template-es6" | ||
} | ||
} | ||
}, | ||
"dependencies": { | ||
"lodash": "" | ||
}, | ||
"devDependencies": { | ||
"oc-template-es6-compiler": "" | ||
} | ||
} |
This file contains 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,5 @@ | ||
const _ = require('lodash'); | ||
|
||
export const data = (context, callback) => { | ||
return callback(null, { name: 'es6' }); | ||
}; |
This file contains 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,4 @@ | ||
.awesome { | ||
font-family: "Hiragino Sans", "ヒラギノ角ゴシック", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Roboto, "Droid Sans", "游ゴシック", YuGothic, "メイリオ", Meiryo, sans-serif; | ||
background: palevioletred; | ||
} |
This file contains 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,4 @@ | ||
import styles from './styles.css'; | ||
|
||
export default ({ name }) => | ||
`<div class=${styles.awesome}>Hello ${name.toUpperCase()}!</div>`; |
This file contains 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 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
39 changes: 25 additions & 14 deletions
39
packages/oc-generic-template-renderer/test/getInfo.test.js
This file contains 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 |
---|---|---|
@@ -1,20 +1,31 @@ | ||
const getInfo = require('../lib/getInfo'); | ||
const packageJson = { | ||
name: 'oc-template-generic', | ||
version: '1.0.0', | ||
externals: { | ||
'lib-one': { | ||
global: 'LibOne', | ||
url: 'https://cdn.com/lib-one/1.0.0/lib-one.min.js' | ||
}, | ||
'lib-two': { | ||
global: 'LibTwo', | ||
url: 'https://cdn.com/lib-two/1.0.0/lib-two.min.js' | ||
} | ||
} | ||
}; | ||
|
||
test('should return the correct info', () => { | ||
const packageJson = { | ||
name: 'oc-template-generic', | ||
version: '1.0.0', | ||
externals: { | ||
'lib-one': { | ||
global: 'LibOne', | ||
url: 'https://cdn.com/lib-one/1.0.0/lib-one.min.js' | ||
}, | ||
'lib-two': { | ||
global: 'LibTwo', | ||
url: 'https://cdn.com/lib-two/1.0.0/lib-two.min.js' | ||
} | ||
} | ||
}; | ||
|
||
const info = getInfo(packageJson); | ||
expect(info).toMatchSnapshot(); | ||
}); | ||
|
||
test('should return an an empty array if the template does not specify any externals', () => { | ||
const packageJson = { | ||
name: 'oc-template-generic', | ||
version: '1.0.0' | ||
}; | ||
|
||
const info = getInfo(packageJson); | ||
expect(info.externals).toEqual([]); | ||
}); |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 OpenComponents community | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,3 @@ | ||
# oc-template-es6-compiler - Compiler module | ||
|
||
OC template to compile components of type `oc-template-es6` |
This file contains 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,11 @@ | ||
'use strict'; | ||
|
||
const compile = require('./lib/compile'); | ||
const template = require('oc-template-es6'); | ||
|
||
module.exports = { | ||
compile, | ||
getInfo: template.getInfo, | ||
getCompiledTemplate: template.getCompiledTemplate, | ||
render: template.render | ||
}; |
Oops, something went wrong.