Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

view-sync

matronator4MIT0.1.2TypeScript support: included

Lightweight alternative to Alpine.js' x-model attribute, that is CSP friendly (no 'unsafe-eval' needed).

view, sync, html5, dom, input sync, alpine, alpinejs, alpine alternative, x-model

readme

view-sync

View Sync logo

NPM Version NPM Downloads npm TypeScript version Tree shaking Dependencies npm package minimized gzipped size Commits Issues License Follow GitHub Sponsors

Lightweight alternative to Alpine.js' x-model attribute, that is CSP friendly (no 'unsafe-eval' needed).

Installation

With npm/yarn/pnpm/bun:

npm i view-sync

Usage

HTML:

<!-- Initialize view-sync and set initial value to "world" -->
<div id="app" data-sync-init="hello" data-sync-value="world">
    <!-- Value of these will be updated with value of `hello` in sync with each other -->
    <input type="text" data-sync="hello">
    <textarea data-sync="hello"></textarea>

    <!-- Text content of this will be updated with value of `hello` -->
    <span data-sync-text="hello"></span>

    <!-- This will be hidden if value of `hello` is falsy -->
    <div data-sync-state="hello">
        I will be hidden if `hello` is falsy
    </div>
</div>

JavaScript/TypeScript:

import { ViewSync } from 'view-sync';
ViewSync.Init();

changelog

Change Log

All notable changes to the "view-sync" project will be documented in this file.

[0.1.0] - 2024-06-29

  • Initial release