Skip to content

Commit d456950

Browse files
committed
Fix #44
1 parent b82e705 commit d456950

File tree

6 files changed

+80
-2
lines changed

6 files changed

+80
-2
lines changed

.meteor/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
local
2+
dev_bundle

.meteor/versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ accounts-base@1.2.8
22
akryum:npm-check@0.0.3
33
akryum:vue@1.0.3
44
akryum:vue-apollo@0.0.6
5-
akryum:vue-app@0.0.1
65
akryum:vue-coffee@0.0.2
76
akryum:vue-component@0.6.2
87
akryum:vue-component-dev-client@0.0.6

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This project contains new meteor packages to help build [meteor](http://meteor.c
99
## Examples
1010

1111
- [Simple example project](https://github.com/Akryum/meteor-vue-example)
12-
- [Blaze example project](https://github.com/Akryum/meteor-vue-blaze)
12+
- [Blaze example project](https://github.com/Akryum/meteor-vue-blaze) [2](https://github.com/Akryum/meteor-vue-blaze/tree/render-blaze)
1313
- [Routing example project](https://github.com/Akryum/meteor-vue-example-routing)
1414
- [i18n example project](https://github.com/Akryum/meteor-vue-example-i18n)
1515
- [Vuex example project](https://github.com/Akryum/meteor-vuex-example)
@@ -33,6 +33,7 @@ Currently supported and possible future features (in no particular order) are:
3333
- [x] Easy routing with vue-router out-of-the-box integration & fast-render
3434
- [x] Easy localization with vue-i18n out-of-the-box integration, auto-detection, server-side injection and key-in-hand ui
3535
- [x] Easy state management with vuex integration
36+
- [x] Use Blaze templates in your vue app
3637
- [ ] *Typescript official integration in .vue files*
3738

3839
Track the project progress [here](https://github.com/Akryum/meteor-vue-component/milestones).
@@ -98,6 +99,14 @@ Manage the state of your app with a centralized data store with [vuex](https://g
9899

99100
[Example app](https://github.com/Akryum/meteor-vuex-example)
100101

102+
### Embed Blaze template
103+
104+
Use Blaze templates inside your vue components.
105+
106+
[See Installation & Usage in akryum:vue-blaze-template](https://github.com/Akryum/meteor-vue-component/tree/master/packages/vue-blaze-template)
107+
108+
[Example app](https://github.com/Akryum/meteor-vue-blaze/tree/render-blaze)
109+
101110
## Get involved
102111

103112
This project is very much a work-in-progress, so your help will be greatly appreciated!

packages/vue-blaze-template/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Use Blaze templates in Vue components
2+
3+
## Installation
4+
5+
meteor add akryum:vue-blaze-template
6+
7+
## Usage
8+
9+
The `v-blaze` directive allow you to use any Blaze template in your Vue component. It expect an expression.
10+
11+
Static template name (**don't forget the single quote**):
12+
13+
```html
14+
<div v-blaze="'loginButtons'"></div>
15+
```
16+
17+
Dynamic template name (will switch the template reactively):
18+
19+
```html
20+
<template>
21+
<div v-blaze="templateName"></div>
22+
</template>
23+
24+
<script>
25+
export default {
26+
data: () => ({
27+
templateName: 'loginButtons'
28+
})
29+
}
30+
</script>
31+
```
32+
33+
[Example app](https://github.com/Akryum/meteor-vue-blaze/tree/render-blaze)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Package.describe({
2+
name: 'akryum:vue-blaze-template',
3+
version: '0.0.1',
4+
summary: 'Render Blaze templates in vue components',
5+
git: 'https://github.com/Akryum/meteor-vue-component',
6+
documentation: 'README.md'
7+
});
8+
9+
Package.onUse(function(api) {
10+
api.versionsFrom('1.3.4.1');
11+
api.use('ecmascript');
12+
api.use('akryum:vue@1.0.3')
13+
api.mainModule('vue-render-blaze.js', 'client');
14+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Vue } from 'meteor/akryum:vue';
2+
import { Template } from 'meteor/templating';
3+
import { Blaze } from 'meteor/blaze';
4+
5+
Vue.directive('blaze', {
6+
bind() {
7+
},
8+
update(newValue, oldValue) {
9+
const templateName = newValue;
10+
const template = Template[templateName];
11+
if(!template) {
12+
throw new Error(`Blaze template '${templateName}' not found.`);
13+
}
14+
if(this.blazeView) {
15+
Blaze.remove(this.blazeView);
16+
}
17+
this.blazeView = Blaze.render(template, this.el);
18+
},
19+
unbind() {
20+
Blaze.remove(this.blazeView);
21+
}
22+
});

0 commit comments

Comments
 (0)