https://github.com/9technology/meta-props
Page configuration via meta tags.
https://github.com/9technology/meta-props
config meta property props
Last synced: 10 months ago
JSON representation
Page configuration via meta tags.
- Host: GitHub
- URL: https://github.com/9technology/meta-props
- Owner: 9technology
- License: bsd-3-clause
- Created: 2016-11-03T01:13:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-15T06:44:16.000Z (over 9 years ago)
- Last Synced: 2025-08-14T13:43:47.169Z (11 months ago)
- Topics: config, meta, property, props
- Language: JavaScript
- Size: 50.8 KB
- Stars: 8
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# meta-props
[](https://travis-ci.org/9technology/meta-props) [](https://coveralls.io/github/9technology/meta-props?branch=master)
Create key-valued hashes from a document's `meta` tags. Useful for reading static configurations from a page.
## Usage
---
```html
import metaProps from 'meta-props';
const props = metaProps();
console.assert(props.foo, 'bar');
```
#### Objects
Properties can be also be deep using a separator, default `:` colon.
```html
const props = metaProps('name');
console.assert(props.foo, 'foo');
console.assert(props.bar.baz, 'baz');
```
#### Arrays
Naming the same `meta` tag will convert the values into an `Array`.
```html
const props = metaProps();
console.assert(Array.isArray(props.array));
console.log(props.array); // ['foo', 'bar', 'baz']
```
#### Casting Value Types
Values can also be type casted via the `type` attribute in the tag.
```html
const props = metaProps();
console.log(typeof props.number); // number
console.log(typeof props.string); // string
console.log(typeof props.boolean); // boolean
console.log(typeof props.json); // object
console.log(typeof props.json.foo); // boolean
console.assert(props.empty === null);
```
## API
---
#### `metaProps([query=null, [separator=":"]])`
- `query` _String_ Used to select prefixed meta tag names.
- `separator` _String_ The split character for building deep hashes.
## License
---
[BSD-3-Clause](LICENSE)
Copyright (c) 2016 [9Technology](https://github.com/9technology)