Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
reshape-component
Advanced tools
[See also: reshape-components
for a more Web Component style API]
This plugin is based on reshape-include
and supports the same functionality.
In addition it provides more component-like paramaterized includes by copying attributes and content from the
component
tag to the template.
For example, in the following use of component
:
<component src="components/Card/Card.html" id="card1" class="active"></component>
The id
and class
attributes will be copied to the first top-level node in the components/Card/Card.html
file.
While this plugin does everything reshape-include
does and more, it is recommended
for clarity's sake to use reshape-include
for simple includes. In case both plugins are in use, this plugin should be
loaded after reshape-include
.
Spike uses reshape-standard
to configure Reshape. Configuration options for Reshape are passed from app.js
, so to add reshape-component
to a Spike project:
npm install reshape-component
reshape-component
in app.js
and add it to the config:// ..
const htmlStandards = require('reshape-standard');
const reshapeComponent = require('reshape-component');
module.exports = {
// ...
reshape: htmlStandards({
// ...
appendPlugins: [
reshapeComponent()
]
})
};
src
and type
attributes are used by the reshape-component
plugin and will not be copiedclass
attribute will be appended to any existing class
attributetype
attributeThis attribute provides a convenience for specifying component types by a short name, e.g.:
<component type="Card" id="card1" class="active"></component>
is equivalent to:
<component src="components/Card/Card.html" id="card1" class="active"></component>
The path is configurable in the options passed to the plugin via the componentPath
property. The default value is:
'components/$type/$type.html'
Any occurrences of $type
in the path will be replaced with the value of the type
attribute.
Tokens can be used as placeholders in a template and will be substituted with content from the component. Tokens can be used for both plain text values and node trees as well.
Card template:
<div class="card" title="${card-name}">
<h1>${card-title}</h1>
<div>${card-body}</div>
</div>
Component that uses the template:
<component type="Card" class="active">
<card-name>Card One</card-name>
<card-title><span class="title">My Title</span></card-title>
<card-body>My Body Content</card-body>
</component>
Result:
<div class="card active" title="Card One">
<h1><span class="title">My Title</span></h1>
<div>My Body Content</div>
</div>
[Object object]
FAQs
Include components in reshape templates
The npm package reshape-component receives a total of 7 weekly downloads. As such, reshape-component popularity was classified as not popular.
We found that reshape-component 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.