Git Product home page Git Product logo

marker's People

Contributors

zambal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

marker's Issues

How can I exclude some functions when I use Marker.HTML?

When a module use Marker.HTML, all tag functions are included. How can I exclude one or more tags from the inclusion list?

Specifically, I want to write like this:

defmodule NanoPlanner.TopView do
  use NanoPlanner.Web, :view
  use Marker.HTML

  def foo(list) do
    div do
      for item <- list do
        span item, class: "item"
      end
    end
  end
end

This causes a compilation error:

** (CompileError) web/templates/top/index.html.eex:2: function link/2 imported from both Phoenix.HTML.Link and Marker.HTML, call is ambiguous

I know that you assume that we use Marker (not Marker.HTML) and define templates for the Phoenix framework, but I want to define a normal function to generate HTML fragment within a view module.

Integration w/ Phoenix helpers does not seem to work...

I would like to use Marker in a Phoenix project, but it seems that it does not know how to deal with encoding the result of phoenix-generate html (i.e. helpers):

  template :index do
    form_for @conn, user_path(@conn, :create), [as: :search], fn f ->
      label "Name: #{text_input f, :name}"
      label "Age: #{select f, :age, 18..100}"
      submit "Submit"
    end
  end
protocol String.Chars not implemented for {:safe, [60, "input", [[32, "id", 61, 34, "search_name", 34], [32, "name", 61, 34, "search[name]", 34], [32, "type", 61, 34, "text", 34]], 62]}. This protocol is implemented for: Atom, BitString, Date, DateTime, Decimal, Ecto.Date, Ecto.DateTime, Ecto.Time, Float, Hound.Element, Integer, List, NaiveDateTime, Postgrex.Copy, Postgrex.Query, Postgrex.Stream, Time, URI, Version, Version.Requirement

Add a .formatter.exs to export the DSL macros as locals without parens

Since v1.6, Elixir features a code formatter. By default, it add parentheses to all functions or macro calls. The first Marker sample code would look like this once formatted:

use Marker.HTML

name = "Vincent"

html do
  body do
    div do
      h3("Person")
      p(name, class: "name")
      p(2 * 19, class: "age")
    end
  end
end

It is however possible to declare locals_without_parens in a .formatter.exs to avoid this behaviour for DSL macros. For libraries like Marker, it is possible to export such configurations and import them in the user’s projects.

We should export all the Marker DSL macros as locals_without_parens.

component macro does not expand well

Hi,

I am trying to use marker to generate some html and it seems the generation is partial.
For instance, let say I have this component in MyTestComponent module

  component :form_input do
    custom_type = @type || "text" # default to text
    # div class: "form-group" do
      label @label, for: @id
      input id: @id,
            type: custom_type,
            class: "a_class",
            placeholder: @placeholder,
            name: "name",
            value: "a value"
    # end
  end

I use the component like this

  use Marker
  use Marker.HTML
  require MyTestComponent
  import MyTestComponent

form_input id: "label", label: "Label", placeholder: "My component name"

The output is missing the label element:

{ :safe, "<input id='label' type='text' class='pure-input-1' placeholder='My component name' name='name' value='a value'/>"}

If I uncomment the div element in the component definition, then I get the result:

I could live with this change but I tried the same for another component:

  component :form_select do
    div class: "form-group" do
      label @label, for: @id
      select @__content__, id: @id, class: "a_class"
    end
  end

And it did not work at all:

form_select id: "method", label: "Method", placeholder: "GET" do
      option "GET", value: "GET"
      option "PUT", value: "PUT"
      option "POST", value: "POST"
      option "DELETE", value: "DELETE"
    end

output has no option at all:

"{ :safe, <div class='form-group'><label for='method'>Method</label><select id='method' class='a_class'></select></div>"}

Any idea what's wrong?
Thanks!

Example Project with Phoenix?

Howdy. This looks really neat. I already see your description that it integrates well with Phoenix...do you have an example "Hello World" project that does this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.