.gitignore000066400000000000000000000000331516110675700130530ustar00rootroot00000000000000/.idea /node_modules /build.npmignore000066400000000000000000000001041516110675700130610ustar00rootroot00000000000000/.idea /artifacts /docs /build /Gemfile /_layouts /_site /_includes .travis.yml000066400000000000000000000001331516110675700131750ustar00rootroot00000000000000language: node_js node_js: - "7" - "node" before_script: - npm install grunt-cli -g Gruntfile.js000066400000000000000000000005171516110675700133670ustar00rootroot00000000000000const builder = require('corifeus-core-builder'); module.exports = (grunt) => { const loader = new builder.Loader(grunt); loader.angular2(builder.config.folder.test.angular2.root); grunt.registerTask('run', builder.config.task.continuous.angular2); grunt.registerTask('default', builder.config.task.build.angular2); }LICENSE.md000066400000000000000000000020561516110675700124760ustar00rootroot00000000000000MIT License Copyright (c) 2017 Patrik Laszlo 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. README.md000066400000000000000000000005431516110675700123500ustar00rootroot00000000000000# ng2-compile-html [![Build Status](https://travis-ci.org/patrikx3/ng2-compile-html.svg?branch=master)](https://travis-ci.org/patrikx3/ng2-compile-html) Angular 2 Service to compile an HTML into a component It is only using ```TypeScript``` right now. It can be built though. ##Install ```bash npm install --save-dev p3x-ng2-compile-html ``` ##Usage package.json000066400000000000000000000031551516110675700133610ustar00rootroot00000000000000{ "name": "p3x-ng2-compile-html", "version": "1.0.4-11", "version-date": "1/16/2017, 5:01:08 PM", "description": "Angular 2 Service to compile an HTML into a component Edit", "main": "src/index.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/patrikx3/ng2-compile-html.git" }, "keywords": [ "p3x", "angular2", "ng2", "compile", "html" ], "author": "Patrik Laszlo ", "license": "MIT", "bugs": { "url": "https://github.com/patrikx3/ng2-compile-html/issues" }, "homepage": "https://github.com/patrikx3/ng2-compile-html#readme", "devDependencies": { "@angular/common": "^2.4.3", "@angular/compiler": "^2.4.3", "@angular/platform-browser": "^2.4.3", "@angular/platform-browser-dynamic": "^2.4.3", "@types/node": "^7.0.0", "angular2-template-loader": "^0.6.0", "awesome-typescript-loader": "^3.0.0-beta.18", "core-js": "^2.4.1", "corifeus-core-builder": "0.0.90-15", "extract-text-webpack-plugin": "^1.0.1", "grunt-webpack": "^1.0.18", "html-loader": "^0.4.4", "html-webpack-plugin": "^2.26.0", "node-sass-css-importer": "0.0.3", "webpack": "^1.14.0", "webpack-dev-server": "^1.16.2", "webpack-merge": "^2.4.0" }, "dependencies": { "@angular/core": "^2.4.3", "rxjs": "^5.0.1", "zone.js": "^0.7.2", "typescript": "^2.1.5" } }src/000077500000000000000000000000001516110675700116565ustar00rootroot00000000000000src/CompileHtmlService.ts000066400000000000000000000015631516110675700157710ustar00rootroot00000000000000import { Component, Compiler, NgModule, Injectable } from '@angular/core'; import {CompileHtmlServiceOptions} from "./CompileHtmlServiceOptions"; @Injectable() export class CompileHtmlService { constructor(private compiler: Compiler) {} public compile(opts: CompileHtmlServiceOptions) { @Component({template: opts.template}) class TemplateComponent { ref = opts.ref; } @NgModule({ imports: opts.imports, declarations: [TemplateComponent] }) class TemplateModule {} const compiled = this.compiler.compileModuleAndAllComponentsSync(TemplateModule); const factory = compiled.componentFactories.find((comp) => comp.componentType === TemplateComponent ); opts.container.clear(); opts.container.createComponent(factory); } }src/CompileHtmlServiceOptions.d.ts000066400000000000000000000003031516110675700175560ustar00rootroot00000000000000import { ViewContainerRef, } from '@angular/core'; export interface CompileHtmlServiceOptions { template: string; container: ViewContainerRef; imports?: any[]; ref?: any } src/index.ts000066400000000000000000000000731516110675700133350ustar00rootroot00000000000000export { CompileHtmlService } from "./CompileHtmlService"; test/000077500000000000000000000000001516110675700120465ustar00rootroot00000000000000test/angular2/000077500000000000000000000000001516110675700135615ustar00rootroot00000000000000test/angular2/app/000077500000000000000000000000001516110675700143415ustar00rootroot00000000000000test/angular2/app/Module.ts000066400000000000000000000006221516110675700161360ustar00rootroot00000000000000import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import {Page } from './Page'; import {CompileHtmlService} from '../../../src/CompileHtmlService'; @NgModule({ imports: [ BrowserModule, ], declarations: [ Page ], providers: [ CompileHtmlService ], bootstrap: [ Page ] }) export class Module { }; test/angular2/app/Page.ts000066400000000000000000000014751516110675700155740ustar00rootroot00000000000000import { Component, Injectable, ViewChild, ViewContainerRef, AfterViewInit } from '@angular/core'; import { CompileHtmlService } from '../../../src/CompileHtmlService'; @Component({ selector: 'p3x-ng2-compile-html', template: ` faszomba
`, }) @Injectable() export class Page implements AfterViewInit{ @ViewChild('container', {read: ViewContainerRef}) container: ViewContainerRef; constructor( private compileHtmlService: CompileHtmlService ) {} alert(string: string ) { alert(string); } ngAfterViewInit() { this.compileHtmlService.compile({ template: `If click works it says OK!`, container: this.container, ref: this, }) } }test/angular2/index.html000066400000000000000000000003421516110675700155550ustar00rootroot00000000000000 p3x-ng2-compile-html test/angular2/main.ts000066400000000000000000000004271516110675700150600ustar00rootroot00000000000000import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import {Module} from './app/Module'; if (process.env.ENV === 'production') { enableProdMode(); } platformBrowserDynamic().bootstrapModule(Module); test/angular2/polyfills.ts000066400000000000000000000004041516110675700161440ustar00rootroot00000000000000import 'core-js/es6'; import 'core-js/es7/reflect'; import 'zone.js/dist/zone'; if (process.env.ENV === 'production') { // Production } else { // Development Error['stackTraceLimit'] = Infinity; require('zone.js/dist/long-stack-trace-zone'); }test/angular2/vendor.ts000066400000000000000000000002351516110675700154260ustar00rootroot00000000000000// Angular import '@angular/platform-browser'; import '@angular/platform-browser-dynamic'; import '@angular/core'; import '@angular/common'; import 'rxjs'; tsconfig.json000066400000000000000000000007131516110675700135770ustar00rootroot00000000000000{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "compilerOptions": { "sourceMap": true }, "lib": [ "es5", "es6", "dom", "es2015.collection", "es2015.promise", "es2015.core" ] } }