Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phx.gen.html.slime generates .hslime files with mixed heex/slime syntax? #1

Open
rsieb opened this issue May 5, 2022 · 1 comment

Comments

@rsieb
Copy link

rsieb commented May 5, 2022

Hi, I have been trying to use your fork "tensiondriven/phoenix_slime" to get slim support in Phoenix 1.6.6.

But it seems this fork does not support generating correct .sheex templates yet?

E.g. when issuing this command in your phoenix_slime_test demo app:

mix phx.gen.html.slime Pets Dog dogs name:string breed:string age:integer weight:integer link:string

...it generates .hslime files in stead of .sheex files:

* creating lib/phoenix_slime_test_web/controllers/dog_controller.ex
* creating lib/phoenix_slime_test_web/templates/dog/edit.html.hslime
* creating lib/phoenix_slime_test_web/templates/dog/form.html.hslime
* creating lib/phoenix_slime_test_web/templates/dog/index.html.hslime
* creating lib/phoenix_slime_test_web/templates/dog/new.html.hslime
* creating lib/phoenix_slime_test_web/templates/dog/show.html.hslime
* creating lib/phoenix_slime_test_web/views/dog_view.ex
* creating test/phoenix_slime_test_web/controllers/dog_controller_test.exs
* creating lib/phoenix_slime_test/pets/dog.ex
* creating priv/repo/migrations/20220505020558_create_dogs.exs
* creating lib/phoenix_slime_test/pets.ex
* injecting lib/phoenix_slime_test/pets.ex
* creating test/phoenix_slime_test/pets_test.exs
* injecting test/phoenix_slime_test/pets_test.exs
* creating test/support/fixtures/pets_fixtures.ex
* injecting test/support/fixtures/pets_fixtures.ex

...and the contents of the files also look like a weird mixture between .heex syntax and .slime syntax:

# lib/phoenix_slime_test_web/templates/dog/form.html.hslime
<.form let={f} for={@changeset} action={@action}>
  <%= if @changeset.action do %>
    <div class="alert alert-danger">
      <p>Oops, something went wrong! Please check the errors below.</p>
    </div>
  <% end %>

  = label f, :name, class: "control-label"
  = text_input f, :name, class: "form-control"
  = error_tag f, :name

  = label f, :breed, class: "control-label"
  = text_input f, :breed, class: "form-control"
  = error_tag f, :breed

  = label f, :age, class: "control-label"
  = number_input f, :age, class: "form-control"
  = error_tag f, :age

  = label f, :weight, class: "control-label"
  = number_input f, :weight, class: "form-control"
  = error_tag f, :weight

  = label f, :link, class: "control-label"
  = text_input f, :link, class: "form-control"
  = error_tag f, :link

  <div>
    <%= submit "Save" %>
  </div>
</.form>

...or just plain .heex syntax with no .slime syntax at all:

# lib/phoenix_slime_test_web/templates/dog/index.html.hslime
<h1>Listing Dogs</h1>

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Breed</th>
      <th>Age</th>
      <th>Weight</th>
      <th>Link</th>

      <th></th>
    </tr>
  </thead>
  <tbody>
<%= for dog <- @dogs do %>
    <tr>
      <td><%= dog.name %></td>
      <td><%= dog.breed %></td>
      <td><%= dog.age %></td>
      <td><%= dog.weight %></td>
      <td><%= dog.link %></td>

      <td>
        <span><%= link "Show", to: Routes.dog_path(@conn, :show, dog) %></span>
        <span><%= link "Edit", to: Routes.dog_path(@conn, :edit, dog) %></span>
        <span><%= link "Delete", to: Routes.dog_path(@conn, :delete, dog), method: :delete, data: [confirm: "Are you sure?"] %></span>
      </td>
    </tr>
<% end %>
  </tbody>
</table>

<span><%= link "New Dog", to: Routes.dog_path(@conn, :new) %></span>

Is generating .slime templates not supported yet or am I doing something wrong? I am new to Phoenix so I prefer to rely on generators for my templates.

@tensiondriven
Copy link
Owner

Hello @rsieb - Sorry for the long delay. As you've probably discovered, no, I didn't do anything special to implement scaffolds/generators in this version.

Now that Liveview 0.18 is out, I am seeing more interest in this module and hoping to get some contributions to add things like this. I have also started working on the package again to get it playing nicely with 0.18 etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants