Skip to content

Commit

Permalink
add "Custom Tags"
Browse files Browse the repository at this point in the history
  • Loading branch information
sebkolind committed May 21, 2024
1 parent 72a0916 commit 3e1190b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@ const Counter: Component<State> = {
mount(document.body, Counter);
```

## 💡 Examples

#### 📖 [Custom Tags](https://github.com/tentjs/tent/#custom-tags)

```typescript
import { type Component, type Children, createTag } from '@tentjs/tent';

// Ideally you would put this in a separate file and export it,
// which would let you use it anywhere in your project.
const customTag = (children: Children, attrs?: object) =>
createTag([
'my-tag',
// Wrap the children in a div with a class of 'container'
// This is just to demonstrate that you can manipulate the children
div(children, { className: 'container' }),
attrs,
]);

const CustomTag: Component = {
view: () => customTag(p('Hello, World!')),
};
```

```html
<my-tag>
<div class="container">
<p>Hello, World!</p>
</div>
</my-tag>
```

## 👍🏻 Contribute

If you want to support the active development of Tent, there are a few ways you can help:
Expand Down

0 comments on commit 3e1190b

Please sign in to comment.