LogoLogo
v2.0.0
v2.0.0
  • 🌸What is Petal Pro?
  • πŸ’‘Changelog
  • ⏫Upgrade guide
  • Guides
    • πŸš€Creating a web app from start to finish
    • 🌎Deploy to Fly.io
    • πŸ’³Adding a subscription
    • πŸ”’Creating Your Own API
  • πŸ‘©β€πŸ³Recipes
    • πŸ’How to apply a recipe with git cherry pick
    • #️⃣UUIDs
    • ✍️First/Last name
    • πŸ—ΊοΈGoogle Maps
    • Password Hashing for Windows
  • Fundamentals
    • πŸ’ΏInstallation
    • πŸ“‚Folder structure
    • πŸ—ƒοΈIncluded Pages
    • πŸ˜€Users & Authentication
    • 🏒Organizations & Multitenancy
    • πŸ’³Stripe billing
    • πŸ””User Notifications
    • 🧊Components
    • ⬛Dark mode
    • 🎨Branding
    • 🌱Seeding
    • πŸ“„Layouts & Menus
    • πŸ–ΌοΈImage uploads
    • πŸ‘₯Impersonation
    • πŸ› οΈBackground Tasks and Jobs
    • πŸ”§Util & Helpers
    • πŸ“§Emails
    • πŸͺJavascript Hooks
    • πŸ“šExtra Hex Libraries
    • πŸ—οΈGenerators
    • πŸ—£οΈTranslations
    • πŸ–οΈContributing
    • πŸ›«Deployment
    • πŸ›‘οΈTesting
    • πŸ”’REST API
Powered by GitBook
On this page
  • Generators
  • mix petal.gen.live
  • mix petal.gen.html

Was this helpful?

  1. Fundamentals

Generators

PreviousExtra Hex LibrariesNextTranslations

Last updated 9 months ago

Was this helpful?

Generators

mix petal.gen.live

This produces the same files as Phoenix's mix phx.gen.live (). The only difference is that the templates use Tailwind and Petal Components. You can try it out with:

mix petal.gen.live Todos Todo todos label:string is_done:boolean

Add the routes from the output.

If you're wondering where to put the routes, you can search in the router file for the text "Add live authenticated routes here", and add them straight after that line.

def PetalProWeb.Router do
  ...

  scope "/", PetalProWeb do
    pipe_through [
      :browser,
      :require_authenticated_user,
      :kick_user_if_suspended_or_deleted,
      :onboard_new_users
    ]
    
    live_session :require_authenticated_user,
      on_mount: {PetalProWeb.UserOnMountHooks, :require_authenticated_user} do
      ...
      
      # Add live authenticated routes here
      live "/todos", TodoLive.Index, :index
      live "/todos/new", TodoLive.Index, :new
      live "/todos/:id/edit", TodoLive.Index, :edit
    
      live "/todos/:id", TodoLive.Show, :show
      live "/todos/:id/show/edit", TodoLive.Show, :edit
    end
  end
  ...
end

mix petal.gen.html

Example:

mix petal.gen.html Todos Todo todos label:string is_done:boolean

Same file output as phx.gen.html (), but uses Petal Components and a layout from Pro.

πŸ—οΈ
docs
docs
After running the generator: the "index" screen
The "new todo" screen
After creating a new todo
The "show" page