Commit graph

171 commits

Author SHA1 Message Date
Mitchell Hanberg bde40756ee
Update ci.yml 2020-12-06 22:58:10 -05:00
Mitchell Hanberg b55708099e
Update FUNDING.yml 2020-12-06 22:53:18 -05:00
Mitchell Hanberg 396978b36c Update test 2020-11-04 20:21:32 -05:00
Mitchell Hanberg aa9a7dd578 Update changelog 2020-11-04 20:11:26 -05:00
Mitchell Hanberg da3dd6b214 Update README 2020-11-04 19:58:35 -05:00
Mitchell Hanberg 5c5edfa67f case expressions 2020-11-04 19:58:35 -05:00
Mitchell Hanberg db110d4241
Merge pull request #99 from Bastes/patch-1
Typo fix in README.md (@behavior => @behaviour)
2020-10-20 09:41:50 -04:00
Michel Belleville f75774c626
Typo fix in README.md (@behavior => @behaviour) 2020-10-20 15:38:46 +02:00
Mitchell Hanberg 7d28953543
Merge pull request #94 from mhanberg/dependabot/hex/ex_doc-0.22.6
Bump ex_doc from 0.22.1 to 0.22.6
2020-09-17 09:42:13 -04:00
dependabot-preview[bot] 7d1c243623
Bump ex_doc from 0.22.1 to 0.22.6
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.22.1 to 0.22.6.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/compare/v0.22.1...v0.22.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-17 10:36:23 +00:00
Mitchell Hanberg 459084285f Fix formatting 2020-08-09 10:10:53 -04:00
Mitchell Hanberg 265c413960 Allow element attrs to be evaluated at runtime
Before this change, only keyword list literals could be passed to
elements. If they had non-literals as values, then those would compile
to EEx expressions.

This allows a non-literal to be passed as attrs and have the entire thing
compile to an EEx expression, which will pass the non-literal to a
"runtime_attrs" function, which evaluates a keyword list into a safe
string.

That last part might need to be reworked if the user is not using
the Phoenix.HTML.Engine EEx Engine.
2020-08-09 10:07:27 -04:00
Mitchell Hanberg ba49ce2b4b Update README 2020-07-25 12:07:00 -04:00
Mitchell Hanberg d4b81d60de Account for the third arg of AST being an atom 2020-07-24 21:27:53 -04:00
Mitchell Hanberg a26c2e3720
Merge pull request #91 from mhanberg/module-components
Module based Component API
2020-07-24 20:39:58 -04:00
Mitchell Hanberg 7be82e003f Module based Component API 2020-07-24 15:54:38 -04:00
Mitchell Hanberg 113a75a7eb
Merge pull request #90 from mhanberg/better-parsers
Parser abstraction
2020-07-23 21:19:58 -04:00
Mitchell Hanberg 8e872e619b Retry integration tests up to 2 more times 2020-07-23 21:17:11 -04:00
Mitchell Hanberg ecc34e084c Remove unused dep 2020-07-23 21:10:11 -04:00
Mitchell Hanberg efd9d84070 Simplify component applicable? callback 2020-07-23 21:06:23 -04:00
Mitchell Hanberg 59e64dce3b Parser abstraction
This implements a Temple.Parser behavior. This contracts requires a
`applicable/1` and `run/2` functions to be defined.

`applicable/1` is passed the unparsed AST, and returns true or false
as to whether this parser module should be run.

`run/2` is passed the unparsed AST as well as the buffer. It should add
parsed markup to the buffer.

The function either returns `:ok` if the AST is done, or
`{:component_applied, ast}`. If the latter is returned, the parser pass
starts over with the return ast.
2020-07-23 20:59:10 -04:00
Mitchell Hanberg 7bf649c4b5 Correctly parse do blocks
Did not correctly parse expressions with do blocks
where the expression had two or more arguments before
the block.
2020-07-22 21:34:50 -04:00
Mitchell Hanberg 2206aa62fe Bump v0.6.0-alpha.4 2020-07-16 00:21:25 -04:00
Mitchell Hanberg f5ad95642a Only split args when list is a keyword list 2020-07-16 00:19:57 -04:00
Mitchell Hanberg bd403a2037 Bump v0.6.0-alpha-3 2020-07-15 23:23:41 -04:00
Mitchell Hanberg 1f599f5f6d Handle expressions with do blocks that aren't if/unless/for 2020-07-15 23:23:12 -04:00
Mitchell Hanberg 3c787297e5 Update README 2020-07-15 22:47:23 -04:00
Mitchell Hanberg 1b02dc86db Bump v0.6.0-alpha.2 2020-07-15 22:42:45 -04:00
Mitchell Hanberg 3da6d275a6
Merge pull request #86 from mhanberg/0-6-components
Components API
2020-07-15 22:41:25 -04:00
Mitchell Hanberg a2917d3bae Update changelog 2020-07-15 22:40:46 -04:00
Mitchell Hanberg 292c91538b Update README 2020-07-15 22:32:27 -04:00
Mitchell Hanberg 1a5837d1b7 Components API
Components work very similarly to how they worked before, but with a few
differences.

To define a component, you can create a file in your configured temple
components directory, which defaults to `lib/components`. You would
probably want ot change that to be `lib/my_app_web/components` if you
are building a phoenix app.

This file should be of the `.exs` extension, and contain any temple
compatible code.

You can then use this component in any other temple template.

For example, if I were to define a `flex` component, I would create a
file called `lib/my_app_web/components/flex.exs`, with the following
contents.

```elixir
div class: "flex #{@temple[:class]}", id: @id do
  @children
end
```

And we could use the component like so

```elixir
flex class: "justify-between items-center", id: "arnold" do
  div do: "Hi"
  div do: "I'm"
  div do: "Arnold"
  div do: "Schwarzenegger"
end
```

We've demonstated several features to components in this example.

We can pass assigns to our component, and access them just like we would
in a normal phoenix template. If they don't match up with any assigns we
passed to our component, they will be rendered as-is, and will become a
normal Phoenix assign.

You can also access a special `@temple` assign. This allows you do
optionally pass an assign, and not have the `@my_assign` pass through.
If you didn't pass it to your component, it will evaluate to nil.

The block passed to your component can be accessed as `@children`. This
allows your components to wrap a body of markup from the call site.

In order for components to trigger a recompile when they are changed,
you can call `use Temple.Recompiler` in your `lib/my_app_web.ex` file,
in the `view`, `live_view`, and `live_component` functions

```elixir
def view do
  quote do
    # ...
    use Temple.Recompiler
    # ...
  end
end
```
2020-07-15 22:32:27 -04:00
Mitchell Hanberg f8f1ec623f Plugin architecture for parsers 2020-07-15 22:32:27 -04:00
zimt28 3d620c7b07
Update Readme (#83)
- Updates version in installation instructions
- Adds `lexs` extension to the live reload and formatter configs
2020-07-14 10:03:42 -04:00
Mitchell Hanberg edb023fd9a Bump v0.6.0-alpha.1 2020-06-30 20:48:08 -04:00
Mitchell Hanberg 4498eabedb Context/LiveView generator 2020-06-30 20:43:04 -04:00
Shritesh Bhattarai a3ec57344a
Fix LiveView engine instruction (#82) 2020-06-16 17:36:12 -04:00
Mitchell Hanberg 853253bc4a Fix README example 2020-06-16 15:52:59 -04:00
Mitchell Hanberg 33c95186fb
Compile to EEx (#80)
Code is gross
2020-06-16 15:28:21 -04:00
Mitchell Hanberg 43bd75056f Add sponsor button 2020-05-16 20:24:47 -04:00
Romain Bertrand c580d4e2fb
Suggest 0.5.0 in README (#76) 2020-05-14 16:04:15 -04:00
Mitchell Hanberg 1ba5d1b88f Update README 2020-04-21 11:24:39 -04:00
Mitchell Hanberg 25284988bb Bump v0.5.0 2020-04-14 10:40:19 -04:00
dependabot-preview[bot] 1ebec6799a Bump ex_doc from 0.21.2 to 0.21.3 (#46)
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.21.2 to 0.21.3.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
dependabot-preview[bot] d09d0276c7 Bump phoenix_ecto from 4.0.0 to 4.1.0 (#32)
Bumps [phoenix_ecto](https://github.com/phoenixframework/phoenix_ecto) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/phoenixframework/phoenix_ecto/releases)
- [Changelog](https://github.com/phoenixframework/phoenix_ecto/blob/master/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix_ecto/compare/v4.0.0...v4.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
dependabot-preview[bot] e379b46ffc Bump floki from 0.23.1 to 0.26.0 (#50)
Bumps [floki](https://github.com/philss/floki) from 0.23.1 to 0.26.0.
- [Release notes](https://github.com/philss/floki/releases)
- [Changelog](https://github.com/philss/floki/blob/master/CHANGELOG.md)
- [Commits](https://github.com/philss/floki/compare/v0.23.1...v0.26.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
dependabot-preview[bot] 03ea32d215 Bump phoenix from 1.4.15 to 1.4.16 (#58)
Bumps [phoenix](https://github.com/phoenixframework/phoenix) from 1.4.15 to 1.4.16.
- [Release notes](https://github.com/phoenixframework/phoenix/releases)
- [Changelog](https://github.com/phoenixframework/phoenix/blob/v1.4.16/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix/compare/v1.4.15...v1.4.16)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
dependabot-preview[bot] 4cdac12ef5 Bump phoenix_html from 2.13.3 to 2.14.1 (#62)
Bumps [phoenix_html](https://github.com/phoenixframework/phoenix_html) from 2.13.3 to 2.14.1.
- [Release notes](https://github.com/phoenixframework/phoenix_html/releases)
- [Changelog](https://github.com/phoenixframework/phoenix_html/blob/master/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix_html/compare/v2.13.3...v2.14.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
dependabot-preview[bot] 77719210a1 Bump ecto from 3.2.1 to 3.4.0 (#65)
Bumps [ecto](https://github.com/elixir-ecto/ecto) from 3.2.1 to 3.4.0.
- [Release notes](https://github.com/elixir-ecto/ecto/releases)
- [Changelog](https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md)
- [Commits](https://github.com/elixir-ecto/ecto/compare/v3.2.1...v3.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-04-14 10:40:17 -04:00
Mitchell Hanberg 764818bf7c Update .tool-versions 2020-04-14 10:40:15 -04:00