rstacruz / expug

Pug templates for Elixir
http://hexdocs.pm/expug
82 stars 3 forks source link

error translating code from html #12

Closed cocodrino closed 6 years ago

cocodrino commented 6 years ago

Hi...I'm having troubles converting this code

<div class="poll-form">
 <h2>New Poll</h2>
 <%= form_for @poll, poll_path(@conn, :create), fn f -> %>
   <label>
     Title:<br />
     <%= text_input f, :title %>
   </label>
   <br />
   <label>
     Options (separated by commas):<br />
     <input type="text" name="options" />
   </label>
   <br />
   <%= submit "Create" %>
 <% end %>
</div>

basically seems that I cant add more one attribute in the input...if I add name attribute I get an error, and the br is a trouble too

.poll-form
    h2 New Poll
    = form_for @poll,poll_path(@conn,:create), fn f ->
        label Title
            = text_input f, :title
        br

        label Options (comma separated)
            input(name="options",type="text")

        = submit "create"

I get this error...

Compiling 1 file (.ex)

== Compilation error in file lib/vocial_web/views/poll_view.ex ==
** (Expug.Error) lib/vocial_web/templates/poll/new.html.pug: Parse error on line 9

                input(name="options",type="text")
                     ^

Expug encountered a character it didn't expect.

    lib/expug.ex:96: Expug.to_eex!/2
    (phoenix_expug) lib/phoenix_expug/engine.ex:24: PhoenixExpug.Engine.read!/1
    (phoenix_expug) lib/phoenix_expug/engine.ex:18: PhoenixExpug.Engine.compile/2
    (phoenix) lib/phoenix/template.ex:378: Phoenix.Template.compile/2
    (phoenix) lib/phoenix/template.ex:186: anonymous fn/3 in Phoenix.Template."MACRO-__before_compile__"/2
    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix) expanding macro: Phoenix.Template.__before_compile__/1
    lib/vocial_web/views/poll_view.ex:1: VocialWeb.PollView (module)
    (elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

what would be the issue here???

thank you

MarbilleJuntado commented 6 years ago

Remove the comma from input(name="options",type="text"). Also, I strongly suggest to align your label and input.

cocodrino commented 6 years ago

thank you I'll check