-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue-renderer): support evaluation in templates (#6505)
- Loading branch information
Showing
8 changed files
with
86 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<head> | ||
{{ HEAD }} | ||
{% if (ENV.NODE_ENV === 'dev') { %} | ||
<!-- debug scripts --> | ||
{% } else if (ENV.NODE_ENV === 'production') { %} | ||
<!-- production scripts --> | ||
{% } %} | ||
</head> | ||
<body> | ||
{{ APP }} | ||
</body> | ||
</html> |
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 @@ | ||
module.exports = { | ||
env: { | ||
NODE_ENV: process.env.NODE_ENV | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"name": "example-custom-template", | ||
"dependencies": { | ||
"nuxt": "latest" | ||
}, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"post-update": "yarn upgrade --latest" | ||
} | ||
} |
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 @@ | ||
<template> | ||
<div class="container"> | ||
<h1>Welcome!</h1> | ||
</div> | ||
</template> |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export default { | ||
appTemplatePath: './test/mytemplate.html' | ||
appTemplatePath: './test/mytemplate.html', | ||
env: { | ||
tracker: 'ga' | ||
} | ||
} |
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 |
---|---|---|
@@ -1,25 +1,57 @@ | ||
import { getPort, loadFixture, Nuxt } from '../utils' | ||
|
||
let port | ||
let nuxt = null | ||
let options | ||
|
||
describe('custom-app-template', () => { | ||
beforeAll(async () => { | ||
const options = await loadFixture('custom-app-template') | ||
nuxt = new Nuxt(options) | ||
options = await loadFixture('custom-app-template') | ||
}) | ||
|
||
test('Home page with google analytics', async () => { | ||
const nuxt = new Nuxt(options) | ||
await nuxt.ready() | ||
|
||
port = await getPort() | ||
const port = await getPort() | ||
await nuxt.server.listen(port, '0.0.0.0') | ||
|
||
const { html } = await nuxt.server.renderRoute('/') | ||
expect(html).toContain('<p>My Template</p>') | ||
expect(html).toContain('<h1>Custom!</h1>') | ||
expect(html).toContain('Google Analytics') | ||
|
||
await nuxt.close() | ||
}) | ||
test('/', async () => { | ||
|
||
test('Home page with heap analytics', async () => { | ||
const nuxt = new Nuxt(options) | ||
options.env.tracker = 'heap' | ||
await nuxt.ready() | ||
|
||
const port = await getPort() | ||
await nuxt.server.listen(port, '0.0.0.0') | ||
|
||
const { html } = await nuxt.server.renderRoute('/') | ||
expect(html).toContain('<p>My Template</p>') | ||
expect(html).toContain('<h1>Custom!</h1>') | ||
expect(html).toContain('Heap Analytics') | ||
|
||
await nuxt.close() | ||
}) | ||
|
||
// Close server and ask nuxt to stop listening to file changes | ||
afterAll(async () => { | ||
test('Home page with no analytics', async () => { | ||
const nuxt = new Nuxt(options) | ||
options.env.tracker = '-' | ||
await nuxt.ready() | ||
|
||
const port = await getPort() | ||
await nuxt.server.listen(port, '0.0.0.0') | ||
|
||
const { html } = await nuxt.server.renderRoute('/') | ||
expect(html).toContain('<p>My Template</p>') | ||
expect(html).toContain('<h1>Custom!</h1>') | ||
expect(html).not.toContain('google Analytics') | ||
expect(html).not.toContain('Heap Analytics') | ||
|
||
await nuxt.close() | ||
}) | ||
}) |