Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@manekinekko/angular-twig

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@manekinekko/angular-twig

Twig template engine support for Angular

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Angular2 ♥ Twig

This (WIP...) experiment is an attempt to add Twig templating support for Angular2

How to use

import {Twig} from 'angular2-twig';

The @Twig decorator supersedes the @Component() decorator.

Use a templateUrl
@Twig({
	templateUrl: 'templates/field--comment.html.twig',
  // -or- template: '',
	context: {
		title: 'Angular2 ❤ Twig',
		content_1: 'content 1',
		content_2: 'content 2'
	},
	selector: '#block-content',
})
export class AppComponent {}
Use an inlined template
@Twig({
  template: `
  <section>
    {% if title %}
      <h2>{{ title }}</h2>
    {% endif %}

    {{ content_1 }}

    {% if content_2 %}
      {{ content_2 }}
    {% endif %}
  </section>
  `,
	context: {
		title: 'Angular2 ❤ Twig',
		content_1: 'content 1',
		content_2: 'content 2'
	},
	selector: '#block-content',
})
export class AppComponent {}

Live Example

Checkout this plnkr for a quick demo.

Acknowledgments

The Twig templates are parsed using (a modified version of) the twig.js library from @justjohn. All credits go to him for the parser.

License

The MIT License

Keywords

FAQs

Package last updated on 28 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc