Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
ractive-load
Advanced tools
Find more Ractive.js plugins at docs.ractivejs.org/latest/plugins
The ractive-load plugin allows you to load Ractive components from HTML files that contain all their markup, CSS and JavaScript. See here for an introduction to components and component files, or visit the demo page.
This plugin works as an AMD module, as a CommonJS module, or as a regular script (it will be exposed as Ractive.load
).
Include ractive-load.js on your page below Ractive, e.g:
<script src='lib/ractive.js'></script>
<script src='lib/ractive-load.js'></script>
To get ractive-load.min.js
you can:
https://cdn.jsdelivr.net/npm/ractive-load@0.6.0/dist/ractive-load.umd.min.js
.$ bower i ractive-load
.$ git clone https://github.com/ractivejs/ractive-load.git
.To load a component, along with any sub-components it depends on:
Ractive.load( 'my-components/foo.html' ).then( function ( FooComponent ) {
var ractive = new FooComponent({
el: 'body',
data: { ... }
});
}).catch( handleError );
If all your components are located in a single folder, you can set the baseUrl
property and the plugin will look for them there:
Ractive.load.baseUrl = 'my-components/';
Ractive.load( 'foo.html' ).then( function ( FooComponent ) {
// use component
}).catch( handleError );
You can load multiple components simultaneously, like so:
Ractive.load({
Foo: 'my-components/foo.html',
Bar: 'my-components/bar.html'
}).then( function ( components ) {
var foo = new components.Foo({
el: 'body',
data: { ... }
});
var bar = new components.Bar({
el: 'body',
data: { ... }
});
}).catch( handleError );
Ideally, components should not care what environment they're being used in - an AMD app, node.js, or a standard browser environment without module loaders.
So if a component has external dependencies, there's a standard way to use them. Suppose you have some app config that sits outside your component:
<p>foo: {{config.foo}}</p>
<script>
var config = require( 'config' );
component.exports = {
data: { config: config }
};
</script>
Here, we're importing the app config with require('config')
. If this component was being used in an AMD app, or if it was being transformed by browserify, it would defer to the AMD or browserify implementation of require
.
But outside of AMD, browserify and node, require
doesn't mean anything. So, inside a component, ractive-load provides a specialised require
function. Using our config
example, require
will first look for Ractive.load.modules.config
, then for window.config
(if we're in a browser), and then will fall back to using an existing require
implementation (e.g. if we're in node.js).
In other words, this is the easiest way to make config
available to a component:
Ractive.load.modules.config = myConfig;
Many components will work in node.js environments without any changes. This allows you to render HTML from components using the same templates and data as you use on the client.
Install it in the usual way:
$ npm i ractive-load
Then, in your app, use it in the normal way:
var load = require( 'ractive-load' );
load( 'my-components/foo.html' ).then( function ( FooComponent ) {
var ractive = new FooComponent({
data: { ... }
});
// generate some HTML so that we can save it, or serve to a client
var renderedHTML = ractive.toHTML();
}).catch( handleError );
Licensed MIT.
Created with the Ractive.js plugin template for Grunt.
0.7.0
FAQs
Component loader plugin for Ractive.js
The npm package ractive-load receives a total of 44 weekly downloads. As such, ractive-load popularity was classified as not popular.
We found that ractive-load demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.