Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
angular-exemplify
Advanced tools
A simple directive for adding code examples based on actual code and markup! Just add `AddExample` to your element and you're done:D
A simple directive for adding code examples based on actual code and markup! Just add AddExample
to your element and you're done:D
Please note that you don't have to use prism and/or bootstrap with angular exemplify although it's recommended.
Run npm install --save angular-exemplify
If you want to use together with prism
Run npm install prismjs
If you want to use together with bootstrap 4
Run npm install bootstrap@4.0.0-alpha.5
Please note the instructions below are for projects based on angular-cli, you might need to set up things differently if you're using something else.
Include scripts and styles in build
If you want to use angular exemplify together with prism, make sure to add the prism script and one of the prism theme css files to your angular-cli.json
config, bootstrap.css is optional:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/prismjs/themes/prism-coy.css",
"styles.css"
],
"scripts": [
"../node_modules/prismjs/prism.js"
],
Import ExemplifyModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { ExemplifyModule } from "../exemplify/exemplify.module";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ExemplifyModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Add AddExample
to your element like this:
<button AddExample class="btn btn-primary" (click)="doSomething()">Action</button>
View demo for live preview and more examples.
Attribute | Type | Usage/description | Default |
---|---|---|---|
target | element | attach example to this element, use local variable | directive element |
source | string | where to get the markup, 'element' or its 'child' | 'element' |
customClass | string | class name added to the directive element | |
externalSources | array | an array of objects specifying external soruces | |
usePrism | boolean | highlight code examples using prismjs (prismjs has to be included) | true |
navStyle | string | customize the style of the nav links, possible values are "tabs", "pills", "inline" see bootstrap for more info. | 'inline' |
keepInputs | boolean | keep attributes attached to the directive element | false |
Using external sources
To keep the examples in sync with your code you should reference the source files. Here's an example based on a app published and deployed to github pages.
externalSources = [{
name:'app.module.ts',
src:'https://raw.githubusercontent.com/hjalmers/angular-markup-example/master/src/app/app.module.ts'
},{
name:'app.component.ts',
src:'https://raw.githubusercontent.com/hjalmers/angular-markup-example/master/src/app/app.component.ts'
},{
name:'app.component.css',
src:'https://raw.githubusercontent.com/hjalmers/angular-markup-example/master/src/app/app.component.css',
language:'css'
}]
FAQs
[![Build Status](https://travis-ci.com/hjalmers/angular-exemplify.svg?branch=master)](https://travis-ci.com/hjalmers/angular-exemplify) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/
We found that angular-exemplify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.