
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
bones-document
Advanced tools
This project provides model validation, editing and rendering helpers. To utilize these helpers defines models that extend the Document
model and describe their schema using JSON-Schema.
When defining new models that extend the Document
model and add a schema attribute. For example;
model = models['Document'].extend({
schema: {
'id': 'Document',
'type': 'object',
'properties': {
'title': {
'type': 'string',
'title': 'Title'
},
'content': {
'type': 'string',
'title': 'Content',
'format': 'markdown'
}
}
}
});
The schema element must be a valid JSON schema. The quick start version of "Using JSON schema in Bones Document" is this;
type
attribute should be populated, and describes the type (e.g. 'string', 'object').format
attribute describes how display should work. this element is not required and by default everything is passed through the model's escape
method. 'markdown' and 'raw' formats are also provided by Bones Document.To complete tests successfully, you must install backbone-stash in bones-document's node_modules/
directory. Then run with
npm test
Models which extend Document
will have a validate
method which can be used (before saving a document to a database, for example) to validate a model's attributes.
TODO
Models which extend Document
will have a renderer
method which returns an object intended to be used from within a template. This Renderer
has a render
method which takes the name of an attribute as an argument and returns the formatted version of that attribute.
A view for displaying a Bones Document may look like:
view = Backbone.View.extend({
render: function() {
$(this.el).html(this.template('post', this.model.renderer()));
return this;
}
});
...and the post
template could contain;
<div class="post">
<h2><%= render('title') %></h2>
<%= render('content') %>
</div>
Of course the default formatters aren't going to be enough. It's possible to provide new ones, and select which formatter is used within a view. To define additional formatters you'll need to add them to the model's prototype. So in /models/post.bones
you may have:
model.prototype.renderers = _.extend({
blinky: function(value) {
return '<blink>' + value '</blink>';
}
}, model.prototype.renderers);
To set a custom formatter to be the default display for a field you just need so set it as the format
of an attribute in the schema.
...
'title': {
'type': 'string',
'title': 'Title',
'format' 'blinky'
},
...
Alternatively, you may pass a set of attribute to formatter mappings in as options when you instantiate a renderer. For, example to specify the blinky
formatter from within a view you could do;
$(this.el).html(this.template(model.renderer({formatters: {title: 'blinky'}})));
FAQs
Unknown package
The npm package bones-document receives a total of 0 weekly downloads. As such, bones-document popularity was classified as not popular.
We found that bones-document demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.