reactionview README

The project's README from github.com/marcoroth/reactionview. As one markdown file: README.md.

ReActionView

ReActionView

Reactive views for the HTML+ERB you already have.

You get what a client-side framework gives you, without adopting one.

No new syntax · No client framework · No API layer · No build step

Gem Version Documentation License Issues


ReActionView makes your existing HTML+ERB templates reactive.

Rails 8.2 already renders HTML templates with Herb::Engine, which reads the HTML and the Ruby in a template together. ReActionView builds on that. A template declares state the browser owns, changes it with an HTML attribute, and has your controller answer when the server is needed. There is no second copy of the page to keep in sync.

It also brings Herb's error overlays, the dev tools and per-tag instrumentation to the page, so a mismatched tag or a <div> inside a <p> shows up in the browser with the file and the line while you work. On Rails 8.1 and earlier, it brings the engine itself.

Documentation

reactionview.dev

Installation

bundle add reactionview
bin/rails generate reactionview:install

The generator creates config/initializers/reactionview.rb and imports the client from app/javascript/application.js. On importmap-rails the gem pins the client for you. With a bundler, install the reactionview npm package as well.

ReActionView needs Ruby 3.2 or newer and Rails 7.0 or newer. Setup covers turning on reactive templates and checking that it works, and the Quick Start builds a first reactive page.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/reactionview. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the ReActionView project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

License

This project is available as open source under the terms of the MIT License.

reactionview (marcoroth/reactionview)

Searching Database…

Что это?ReActionView делает ваши существующие HTML+ERB-шаблоны в Rails реактивными на клиенте, без отдельного JavaScript-фреймворка, API-слоя или этапа сборки. Состояние живёт в HTML-атрибуте, браузер сам обновляет страницу и обращается к серверу, только когда это действительно нужно.
Это новый шаблонный язык или он работает с моим существующим ERB?Это не новый синтаксис. Он строится прямо на ваших существующих HTML+ERB-шаблонах, используя Herb::Engine — движок, который Rails 8.2 уже применяет, чтобы разбирать HTML и встроенный Ruby шаблона вместе.
Как добавить его в Rails-приложение?Добавьте гем и запустите его генератор, который создаёт config/initializers/reactionview.rb и подключает клиент в app/javascript/application.js. С importmap-rails гем сам закрепляет клиент; при использовании бандлера нужно ещё установить npm-пакет reactionview.
Какие версии Rails и Ruby нужны?Нужны Ruby 3.2+ и Rails 7.0+. На Rails 8.1 и старее, где Herb::Engine ещё не входит в комплект, ReActionView приносит сам движок.
Не получится ли двух копий состояния страницы, которые придётся синхронизировать?Нет — шаблон объявляет состояние, которым владеет и которое меняет браузер через HTML-атрибут, а контроллер отвечает, только когда сервер действительно нужен, поэтому нет отдельного клиентского состояния, которое пришлось бы согласовывать со страницей, отрендеренной сервером.
Какую помощь в отладке он добавляет при разработке?Он приносит в браузер оверлеи ошибок Herb, инструменты разработчика и инструментирование по каждому тегу, так что несоответствующий тег подсвечивается с точным файлом и строкой прямо во время работы.
Где найти полную документацию по установке и использованию?Полная документация, включая руководство по установке и Quick Start по созданию первой реактивной страницы, находится на reactionview.dev.
Что такое Herb и почему этот гем от него зависит?Herb (Herb::Engine) — это движок парсинга, штатный для Rails 8.2, который читает HTML и встроенный Ruby шаблона вместе; ReActionView строит свои реактивные возможности поверх этого движка.
Creator
marcoroth
Size
0.8 MB
Stars
531
Age
1y
Commits · 90 Days