https://github.com/bttmly/tack
jQuery-inspired syntax for constructing HTML strings
https://github.com/bttmly/tack
Last synced: 3 months ago
JSON representation
jQuery-inspired syntax for constructing HTML strings
- Host: GitHub
- URL: https://github.com/bttmly/tack
- Owner: bttmly
- Created: 2014-08-11T04:48:14.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-13T00:10:27.000Z (over 10 years ago)
- Last Synced: 2025-02-10T12:39:13.220Z (3 months ago)
- Language: CoffeeScript
- Size: 316 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tack [](https://travis-ci.org/nickb1080/tack)
jQuery-inspired syntax for building HTML strings.
## Factory
### `tack(String tagName | Element el | Object options)`
`tack()` is the factory function for `Tack` instances.
When passed a `tagName`, builds an instance with that value as it's tag name.
When passed a DOM element `el`, builds an instance from the properites of that element.
When passed an `options` object, builds an instance into which `options` are merged## Instance Methods
### `.attr(String name, [String value])`
**Get signature**: When `value` isn't provided, returns the instance's value for the attribute `name`.**Set signature**: When `value` is provided, sets the instance's `name` attribute to `value` and returns the instance.
### `.removeAttr(String name)`
Removes the attribute called `name` from the instance.### `.id([String value])`
**Get signature**: When `value` isn't provided, returns the instance's value for the "id" attribute.**Set signature**: When `value` is provided, sets the instance's "id" attribute to `value` and returns the instance.
### `.addClass(String className)`
Adds a space-separated list of classes to the instance.### `.removeClass(String className)`
Removes a space-separated list of classes from the instance.### `.toggleClass(String className)`
Toggles a space-separated list of classes on the instance.### `.hasClass(String className)`
Returns whether or not an instance has each class in a space-separated list of classes.### `.addChild(param)`
Creates a new instance from by passing `param` to the `tack()` factory, and adds it to the instance's children.### `.childAt(Number index)`
Returns the child at `index` in an instance's children.### `.render()`
Builds the corresponding HTML for an instance (recursively calling render as appropriate on each child).### `.create()`
Creates a DOM node from an instance.### `.clone()`
Returns a new deep copy (i.e. children are recursively copied) of an instance.## Static Methods
### `.extend(Object methods)`
Extends `Tack.prototype` with `methods`.