4.0.1 • Published 5 years ago

@rd/compiler v4.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Circle CI Badge codecov Dependency Status Dev Dependency Status Peer Dependency Status NPM Downloads NPM Version MIT License

@rd/compiler Public or Private Repo

This module contains a simple easy to use angular2+ template compiler

It is useful when you need to compile any angular2+ template file directly to html, passing in a view model as a parameter, similar to $ngCompiler in angular.js!!

Installation

npm install @rd/compiler --save

Example(s)

TemplateCompiler

@Component({
  template:
    `<div #divViewContainerRef></div>`
})
export class TemplateCompilerExampleComponent {
  @ViewChild('divViewContainerRef', { read: ViewContainerRef }) divViewContainerRef: ViewContainerRef;

  compiledHtml: string;

  constructor(public templateCompiler: TemplateCompiler) { }

  ngOnInit(){
    this.templateCompiler.compile('/src/assets/auto-email-template.html', { id: 291, firstName: 'chase', lastName: 'gibbs' }, this.divViewContainerRef, [SharedModule]).subscribe((compiledResult: CompiledResultModel) => {
        this.compiledHtml = compiledResult.styles + compiledResult.outerHTML;
    });
  }

}

/src/assets/auto-email-template.html

<style id="styleId">
	.className {
		height: 10px;
	}
</style>

<div id="name">
    <span *ngIf="model?.firstName">{{model.firstName}}</span>
    <span *ngIf="model?.lastName">&nbsp;{{model.lastName}}</span>
</div>

<h1>
    hello world!!
</h1>

<button class="btn btn-default">btn</button>

Contributing

In order to contribute to this package, please make any changes on your own feature branch and create a pull-request for review (see below for more info)

In order to release this package automatically, you must format the commit message properly so that when it is merged into master, it will semantically release the new changes based on commit msg type and previously tagged version. (by running npm run commit instead of git commit, it will run a interactive command-line utility which will ultimately format the commit messages properly for you)

Don't forget to expose any new additions publicly, ensure everything which is public is accessible via the public_api.ts

-> Code review guidelines for this project

-> Coding standards for this project

-> Contribution guidelines for this project

powered by: https://rentdynamics.com + https://angular.io

4.0.1

5 years ago

4.0.0

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago