You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Webpack loader for Framework7 single file router components
3
+
> Webpack loader for Framework7 single file components
4
4
5
5
## What is Framework7 Component Loader?
6
6
7
-
`framework7-component-loader` is a loader for [webpack](https://webpack.js.org/) that allows you to author [Framework7 Router components](http://framework7.io/docs/router-component.html) in a format called [Single-File Components](http://framework7.io/docs/router-component.html#single-file-component):
7
+
`framework7-loader` is a loader for [webpack](https://webpack.js.org/) that allows you to author [Framework7 Router components](http://framework7.io/docs/router-component.html) in a format called [Single-File Components](http://framework7.io/docs/router-component.html#single-file-component):
8
8
9
9
```html
10
10
<!-- my-page.f7.html -->
11
11
<template>
12
-
<divclass="page">{{msg}}</div>
13
-
<!-- Inline partials -->
14
-
{{> 'foo'}} {{> 'bar'}}
15
-
<!-- External partials -->
16
-
{{> 'external'}}
12
+
<divclass="page">${msg}</div>
17
13
</template>
18
14
19
-
<!-- Template7 inline partial support (optional) -->
20
-
<template-partialid="foo">
21
-
<div>foo</div>
22
-
</template-partial>
23
-
<template-partialid="bar">
24
-
<div>bar</div>
25
-
</template-partial>
26
-
27
15
<script>
28
-
exportdefault {
29
-
data() {
30
-
return {
31
-
msg:'Hello world!',
32
-
};
33
-
},
16
+
exportdefault () => {
17
+
constmsg='Hello world';
18
+
19
+
return $render;
34
20
};
35
21
</script>
36
22
```
37
23
38
-
#### External partial templates example (see config for location)
39
-
40
-
```html
41
-
<!-- external.f7p.html -->
42
-
<template>
43
-
<div>External template get scope context {{msg}}</div>
44
-
</template>
45
-
```
46
-
47
24
## Installation
48
25
49
26
```
50
-
npm i framework7-component-loader
27
+
npm i framework7-loader
51
28
```
52
29
53
30
## Configuration
@@ -62,19 +39,7 @@ module.exports = {
62
39
test:/\.f7.html$/,
63
40
use: [
64
41
'babel-loader',
65
-
{
66
-
loader:'framework7-component-loader',
67
-
options: {
68
-
// path to file that exports array of Template7 helpers names
69
-
helpersPath:'./src/template7-helpers-list.js',
70
-
// path where to look for Template7 partials
71
-
partialsPath:'./src/pages/',
72
-
// Template7 partials file extension
73
-
partialsExt:'.f7p.html',
74
-
// When enabled it will minify templates HTML content
75
-
minifyTemplate:true,
76
-
}
77
-
}
42
+
'framework7-loader',
78
43
],
79
44
},
80
45
@@ -85,36 +50,27 @@ module.exports = {
85
50
}
86
51
```
87
52
88
-
## Template7 Helpers
53
+
## JSX
89
54
90
-
To use Template7 helpers, we need to specify helpers names in separate file and specify path to file in `helpersPath` loader parameter. It is required because template is compiled on server side which doesn't know about helpers registered during app runtime.
55
+
Framework7 v6 single file components also support JSX:
91
56
92
-
So, if we use helpers named `foo` and `bar` in our templates, we need to register their names in file:
57
+
```html
58
+
<!-- my-page.f7.html -->
59
+
<script>
60
+
exportdefault () => {
61
+
constmsg='Hello world';
93
62
94
-
```js
95
-
/* src/template7-helpers-list.js */
96
-
module.exports= ['foo', 'bar'];
63
+
return () =><div class="page">{msg}</div>;
64
+
};
65
+
</script>
97
66
```
98
67
99
-
And specify this file in loader options:
100
-
101
68
```js
102
-
rules: [
103
-
...
104
-
{
105
-
test:/\.f7.html$/,
106
-
use: [
107
-
'babel-loader',
108
-
{
109
-
loader:'framework7-component-loader',
110
-
options: {
111
-
// path to file that exports array of Template7 helpers names
0 commit comments