This is a template of an app with a setup that allows Svelte components to be used in combination with ERB templates to render views.
This also includes:
.svelte
filesroutes.rb
and Rails view files. See vite.config.ts
for details..svelte
components into .html.erb
templates using <svelte-*>
syntax. See app/frontend/svelte/index.ts
for details.You will find Svelte components in app/frontend/svelte/
. To add them to a Rails view (.html.erb
file), see details in app/frontend/svelte/index.ts
.
Example:
See app/views/home/index.html.erb
:
<svelte-home data-props="<%= @data.to_json %>"></svelte-home>
bundle install
yarn
bundle exec rails s
bin/vite dev