Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
content-tag
Advanced tools
Readme
content-tag
is a preprocessor for JS files that are using the content-tag proposal. This originated with Ember.js' GJS and GTS functionality. You can read more by checking out the original RFC
This preprocessor can be used to transform files using the content-tag
spec to standard JS. It is built on top of swc using Rust and is deployed as a wasm package.
npm install content-tag
let { Preprocessor } = require('content-tag');
let p = new Preprocessor();
let output = p.process('<template>Hi</template>');
console.log(output);
import { Preprocessor } from 'content-tag';
let p = new Preprocessor();
let output = p.process('<template>Hi</template>');
console.log(output);
import { Preprocessor } from 'content-tag';
let p = new Preprocessor();
let output = p.process('<template>Hi</template>');
console.log(output);
Preprocessor
All content-tag
public API lives on the Preprocessor
object.
Preprocessor.process(src: string, options?: PreprocessorOptions): string;
Parses a given source code string using the content-tag
spec into standard
JavaScript.
import { Preprocessor } from 'content-tag';
let p = new Preprocessor();
let output = p.process('<template>Hi</template>');
Preprocessor.parse(src: string, options?: PreprocessorOptions): Parsed[];
Parses a given source code string using the content-tag
spec into an array of
Parsed
content tag objects.
import { Preprocessor } from 'content-tag';
let p = new Preprocessor();
let output = p.parse('<template>Hi</template>');
PreprocessorOptions
interface PreprocessorOptions {
/** Default is `false` */
inline_source_map?: boolean;
filename?: string;
}
Parsed
NOTE: All ranges are in bytes, not characters.
interface Parsed {
/**
* The type for the content tag.
*
* 'expression' corresponds to a tag in an expression position, e.g.
* ```
* const HiComponent = <template>Hi</template>;
* ```
*
* 'class-member' corresponds to a tag in a class-member position, e.g.
* ```
* export default class HiComponent extends Component {
* <template>Hi</template>
* }
* ```
*/
type: "expression" | "class-member";
/**
* Currently, only template tags are parsed.
*/
tagName: "template";
/** Raw template contents. */
contents: string;
/**
* Byte range of the contents, inclusive of inclusive of the
* `<template></template>` tags.
*/
range: {
start: number;
end: number;
};
/**
* Byte range of the template contents, not inclusive of the
* `<template></template>` tags.
*/
contentRange: {
start: number;
end: number;
};
/** Byte range of the opening `<template>` tag. */
startRange: {
end: number;
start: number;
};
/** Byte range of the closing `</template>` tag. */
endRange: {
start: number;
end: number;
};
}
See the CONTRIBUTING.md file.
FAQs
A rust program that uses a fork of swc to parse and transform Javascript containing the content-tag proposal
The npm package content-tag receives a total of 72,660 weekly downloads. As such, content-tag popularity was classified as popular.
We found that content-tag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.