Skip to content

Commit

Permalink
chore: update twig support for angular v2+
Browse files Browse the repository at this point in the history
  • Loading branch information
Wassim CHEGHAM committed Apr 28, 2017
1 parent d404693 commit 9b8590c
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 86 deletions.
74 changes: 39 additions & 35 deletions package.json
@@ -1,36 +1,40 @@
{
"name": "angular2-twig",
"version": "1.0.0",
"description": "Twig template engine support for Angular2",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/manekinekko/angular2-twig.git"
},
"keywords": [
"twig",
"angular2",
"template",
"engine"
],
"author": "Wassim Chegham <wassim.chegham@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/manekinekko/angular2-twig/issues"
},
"engines": {
"node": ">= 5.4.1 < 6"
},
"homepage": "https://github.com/manekinekko/angular2-twig#readme",
"dependencies": {
"angular2": "2.0.0-beta.6",
"es6-shim": "^0.33.8",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "^0.19.16",
"zone.js": "0.5.14"
}
}
"name": "@manekinekko/angular-twig",
"version": "1.0.0",
"description": "Twig template engine support for Angular",
"main": "twig-decorator.js",
"scripts": {
"start": "tsc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/manekinekko/angular-twig.git"
},
"keywords": [
"twig",
"angular",
"template",
"engine"
],
"author": "Wassim Chegham <contact@wassimchegham.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/manekinekko/angular-twig/issues"
},
"engines": {
"node": ">= 5.4.1 < 8"
},
"homepage": "https://github.com/manekinekko/angular-twig#readme",
"dependencies": {
"@angular/core": "^4.0.0",
"es6-shim": "^0.35.3",
"rxjs": "^5.1.0",
"reflect-metadata": "0.1.2",
"zone.js": "^0.8.4",
"twig": "^1.10.4"
},
"devDependencies": {
"@types/node": "~6.0.60",
"typescript": "~2.2.0"
}
}
32 changes: 19 additions & 13 deletions tsconfig.json
@@ -1,14 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"outDir": ".",
"rootDir": ".",
"sourceMap": true,
"declaration": true
},
"exclude": [
"node_modules"
]
}
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"outDir": ".",
"rootDir": ".",
"sourceMap": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
]
},
"exclude": [
"node_modules"
]
}
2 changes: 1 addition & 1 deletion twig-decorator.d.ts
@@ -1 +1 @@
export declare function Twig(args?: {}): (cls: any) => void;
export declare function Twig(args?: any): (cls: any) => void;
36 changes: 18 additions & 18 deletions twig-decorator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion twig-decorator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 14 additions & 18 deletions twig-decorator.ts
@@ -1,17 +1,13 @@
import {
Component
} from 'angular2/core';
} from '@angular/core';
import {twig} from 'twig';

import {
PromiseWrapper
} from 'angular2/src/facade/async';

var twig: Function = (<any>window).twig;
declare var Reflect;

export function Twig(args:any={}) {
return function TwigDecorator(cls) {
args.template = RenderSync(args);
args.templateUrl = '';
TwigComponent(args)(cls);
};
}
Expand Down Expand Up @@ -49,16 +45,16 @@ function RenderSync(args) {

// Not working for now because decorators are resolved synchronously!
function RenderAsync(args) {
var completer = PromiseWrapper.completer();
twig({
id: 'RenderAsync',
href: args.templateUrl,
load: (template) => {
let tpl = template.render(args.context);
console.log('annotation Twig OK');
completer.resolve(tpl);
},
error: completer.reject
return new Promise( (resolve, reject) => {
twig({
id: 'RenderAsync',
href: args.templateUrl,
load: (template) => {
let tpl = template.render(args.context);
console.log('annotation Twig OK');
resolve(tpl);
},
error: reject
});
});
return completer.promise;
}
80 changes: 80 additions & 0 deletions yarn.lock
@@ -0,0 +1,80 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@angular/core@^4.0.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-4.1.0.tgz#72ec173316879571880c9c483ed6dfc0caab94b0"

"@types/node@~6.0.60":
version "6.0.71"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.71.tgz#aa49e0109e35f1457867b45822caf7f4883ca248"

balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"

brace-expansion@^1.0.0:
version "1.1.7"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
dependencies:
balanced-match "^0.4.1"
concat-map "0.0.1"

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

es6-shim@^0.35.3:
version "0.35.3"
resolved "https://registry.yarnpkg.com/es6-shim/-/es6-shim-0.35.3.tgz#9bfb7363feffff87a6cdb6cd93e405ec3c4b6f26"

foreachasync@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/foreachasync/-/foreachasync-3.0.0.tgz#5502987dc8714be3392097f32e0071c9dee07cf6"

locutus@^2.0.5:
version "2.0.8"
resolved "https://registry.yarnpkg.com/locutus/-/locutus-2.0.8.tgz#557d669e39999dea03d1b0ac1d9e9bab8e81e4f7"

minimatch@3.0.x:
version "3.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
dependencies:
brace-expansion "^1.0.0"

reflect-metadata@0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.2.tgz#ea23e5823dc830f292822bd3da9b89fd57bffb03"

rxjs@^5.1.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.3.0.tgz#d88ccbdd46af290cbdb97d5d8055e52453fabe2d"
dependencies:
symbol-observable "^1.0.1"

symbol-observable@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"

twig@^1.10.4:
version "1.10.4"
resolved "https://registry.yarnpkg.com/twig/-/twig-1.10.4.tgz#2ebad1e7e38c02b9cc772934822da1163d4ad4a1"
dependencies:
locutus "^2.0.5"
minimatch "3.0.x"
walk "2.3.x"

typescript@~2.2.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c"

walk@2.3.x:
version "2.3.9"
resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.9.tgz#31b4db6678f2ae01c39ea9fb8725a9031e558a7b"
dependencies:
foreachasync "^3.0.0"

zone.js@^0.8.4:
version "0.8.9"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.9.tgz#34aaa9a3ec6d0e4acebd1b761adafa590473638b"

0 comments on commit 9b8590c

Please sign in to comment.