temple

An HTML DSL for Elixir and Phoenix

MIT License

Downloads
52.8K
Stars
486
Committers
13

Bot releases are hidden (Show)

temple - v0.11.0

Published by mhanberg over 1 year ago

What's Changed

Full Changelog: https://github.com/mhanberg/temple/compare/v0.10.0...v0.11.0

temple - v0.10.0

Published by mhanberg about 2 years ago

What's Changed

Full Changelog: https://github.com/mhanberg/temple/compare/v0.9.0...v0.10.0

temple - v0.9.0

Published by mhanberg about 2 years ago

temple - v0.9.0-rc.0

Published by mhanberg over 2 years ago

Breaking Changes

  • Requires Elixir 1.13+
  • Whitespace control is now controlled by whether you use do/end or :do syntax. The :do syntax will render "tight" markup.
  • Components are no longer module based. Any function can now be a component. Now to render a component, you pass a function reference c &my_component/1.
    • Temple.Component has been removed, which removes the render/1 macro for defining a component. Now all you need to do is define a function and have it take an assigns parameter and call the temple/1 macro that is imported from Temple.
    • The defcomp macro has been removed, since now all you need is a function.
  • All Phoenix related things and dependencies have been removed. If you are going to use Temple with Phoenix, now use the temple_phoenix package instead.
  • Config options have changed. Now all you can configure are the aliases (unchanged from before) and now you can configure the EEx.Engine to use. By default it uses EEx.SmartEngine.

Please see the guides for more in depth migration information.

temple - v0.8.0

Published by mhanberg about 3 years ago

  • Better whitespace handling and control (#145)

    • Fine tune whitespace

    The EEx outut now emits more human-readable and predictable formatting.
    This includes proper indenting, at least for each "root" template.

    • Internal whitespace control

    You can now use a bang version of any nonvoid tag to emit the markup
    witout the internal whitespace. This means that there will not be a
    newline emitted after the opening tag and before the closing tag.

temple - v0.7.0

Published by mhanberg over 3 years ago

  • Properly emit boolean attributes (#139)
  • Class object syntax (#140)
temple - v0.6.2

Published by mhanberg over 3 years ago

Bug fixes

  • Compile void elements with zero attrs #135
temple - v0.6.1

Published by mhanberg over 3 years ago

Bug fixes

  • Only collect slots in the root of a component instance #127
temple - v0.6.0

Published by mhanberg over 3 years ago

Temple now is written to be fully compatible with Phoenix LiveView! This comes with substantial internal changes as well as a better component API.

Phoenix LiveView

Temple now outputs LiveView compatible EEx at compile time, which is fed right into the normal LiveView EEx engine (or the traditional HTML Engine if you are not using LiveView).

Components

Temple now has a more complete component API.

Components work with anywhere, whether you are writing a little plug app, a vanilla Phoenix app, or a Phoenix LiveView app!

Please see the documenation for more information.

To migrate component from the 0.5.0 syntax to the 0.6.0 syntax, you can use the following as a guide

# 0.5.0

# definition
defmodule PageView do
  defcomponent :flex do
    div id: @id, class: "flex" do
      @children
    end
  end
end

# usage

require PageView
# or 

import PageView

temple do
  PageView.flex id: "my-flex" do
    div "Item 1"
    div "Item 2"
    div "Item 3"
  end

  # with import
  flex id: "my-flex" do
    div "Item 1"
    div "Item 2"
    div "Item 3"
  end
end

to

# 0.6.0

# definition

defmodule Flex do
  import Temple.Component

  render do
    div id: @id, class: "flex" do
      slot :default
    end
  end
end

# usage

temple do
  c Flex id: "my-flex" do
    div do: "Item 1"
    div do: "Item 2"
    div do: "Item 3"
  end
end

Other breaking changes

0.6.0 has been a year in the making and a lot has changed in that time (in many cases, several times over), and I honestly can't really remember everything that is different now, but I will list some things here that I think you'll need to change or look out for.

  • The partial macro is removed.
    • You can now just call the render function like you normally would to render a phoenix partial.
  • The defcomponent macro is removed.
    • You now define components using the API described above.
  • The text macro is now removed.
    • You can just use a string literal or a variable to emit a text node.
  • Elements and components no longer can take "content" as the first argument. A do block is now required, but you can still use the keyword list style for a concise style, e.g., span do: "foobar" instead of span "foobar".
  • The :compact reserved keyword option was removed.
  • The macros that wrapped Phoenix.HTML are removed as they are no longer needed.
  • The temple.convert task has been removed, but I am working to bring it back.

There might be some more, so if you run into any problems, please open a GitHub Discussion.

temple - v0.6.0-rc.1

Published by mhanberg over 3 years ago

Enhancements

  • Components can now use slots.
  • Markup is 100% live view compliant.

Breaking

  • @inner_content is removed in favor of invoking the default slot.
  • The compact reserved keyword for elements has been removed. This is not really intentional, just a side effect of getting slots to a usable place. I expect to add it back, or at least similar functionality in the future.
Package Rankings
Top 9.55% on Proxy.golang.org
Top 8.44% on Hex.pm
Badges
Extracted from project README
Actions Status Hex.pm