Commit graph

235 commits

Author SHA1 Message Date
Mitchell Hanberg 07c82e21d3
Dynamic Attributes (#190)
* Move directories for ast tests to match convention

* feat!: Rename `:let` to `:let!`

We use the "bang" style as the reserved keyword to differentiate it from
other possible attributes.

* feat: use Phoenix.HTML as the default engine

I am choosing to leverage this library in order to quickly get dynamic
attributes (see #183) up and running.

This also ensures that folks who wish to use Temple outside of a Phoenix
project with get some nice HTML functions as well as properly escaped
HTML out of the box.

This can be made optional if Temple becomes decoupled from the render
and it including HTML specific packages becomes a strange.

* feat: Allow user to make their own Component module

The component module is essentially to defer compiling functions that the
user might not need. The component, render_slot, and inner_block functions
are only mean to be used when there isn't another implementation.

In the case of a LiveView application, LiveView is providing the
component runtime implementation. This was causing some compile time
warnings for temple, because it was using the LiveView engine at compile
time (for Temple, not the user's application) and LiveView hadn't been
compiled or loaded.

So, now we defer this to the user to make their own module and import it
where necessary.

* feat: Pass dynamic attributes with the :rest! attribute

The :rest! attribute can be used to pass in a dynamic list of attributes
to be mixed into the static ones at runtime.

Since this cannot be properly escaped by any engine, we have to mark it
as safe and then allow the function to escape it for us. I decided to
leverage the `attributes_escape/1` function from `phoenix_html`. There
isn't really any point in making my own version of this or vendoring it.

Now you can also pass a variable as the attributes as well if you only
want to pass through attributes from a calling component.

The :rest! attribute also works with components, allowing you to pass
a dynamic list of args into them.

Fixes #183

* Move test components to their own file.

* docs(components): Update documentation on Temple.Components

* docs(guides): Mention attributes_escape/1 function in the guides

* chore(test): Move helper to it's own module

* feat: rest! support for slots

* docs(guides): Dynamic attributes

* ci: downgrade runs-on to support OTP 23
2023-01-21 06:44:29 -05:00
dependabot[bot] 85eb81944e
Bump ex_doc from 0.29.0 to 0.29.1 (#191) 2022-11-22 08:13:45 -05:00
dependabot[bot] f6c4340c98
Bump floki from 0.33.1 to 0.34.0 (#189)
Bumps [floki](https://github.com/philss/floki) from 0.33.1 to 0.34.0.
- [Release notes](https://github.com/philss/floki/releases)
- [Changelog](https://github.com/philss/floki/blob/main/CHANGELOG.md)
- [Commits](https://github.com/philss/floki/compare/v0.33.1...v0.34.0)

---
updated-dependencies:
- dependency-name: floki
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-11 22:28:35 -05:00
Mitchell Hanberg f4ce790411
fix: runtime boolean attributes (#188)
Closes #187
2022-11-11 22:28:05 -05:00
dependabot[bot] 61aea98d9e
Bump ex_doc from 0.28.6 to 0.29.0 (#186)
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.28.6 to 0.29.0.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/compare/v0.28.6...v0.29.0)

---
updated-dependencies:
- dependency-name: ex_doc
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-26 23:20:17 -04:00
dependabot[bot] d349b0992c
Bump ex_doc from 0.28.5 to 0.28.6 (#185)
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.28.5 to 0.28.6.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/compare/v0.28.5...v0.28.6)

---
updated-dependencies:
- dependency-name: ex_doc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-16 21:33:32 -04:00
Mitchell Hanberg db231e7b6b
Align component model with HEEx/Surface (#182)
* Align component model with HEEx/Surface

This change aligns the component model with HEEx/Surface. This shoudl
allow one to interop components created in any syntax with any other
syntax.

The advantage of this is folks can utilize component packages created
using a different syntax.

This includes several enhancements and breaking changes, please see the changelog and the migration guide for further details.

Closes #130
2022-10-12 09:17:23 -04:00
Mitchell Hanberg dca47b9802 Bump v0.10.0 2022-09-19 20:37:10 -04:00
Mitchell Hanberg 99cbb42962
SVG (#181)
This basically just adds svg elements as void and nonvoid element
aliases and it works, will test on a real proejct before releasing the
next release.

Also, fixed the weird behaviour problem by defining types for each of the ast
nodes and then referencing those types when defining the ast type.

Unclear why this works, but I imagine it has to do with the types not
being a big part of the compilation process or something.

This also uses the typed_struct library to do so. Seems pretty slick and
does what it claims it does.
2022-09-19 20:35:45 -04:00
dependabot[bot] f9ccfbc718
Bump ex_doc from 0.28.4 to 0.28.5 (#179)
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.28.4 to 0.28.5.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/v0.28.5/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/compare/v0.28.4...v0.28.5)

---
updated-dependencies:
- dependency-name: ex_doc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-11 22:41:28 -04:00
Mitchell Hanberg 2f042506b6
feat: Mix task to convert HTML into Temple (#180) 2022-09-11 22:39:31 -04:00
Mitchell Hanberg e28504a037 Bump v0.9.0 2022-09-01 14:32:01 -06:00
dependabot[bot] 21e3c7e3a2
Bump ex_doc from 0.28.3 to 0.28.4 (#178)
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.28.3 to 0.28.4.
- [Release notes](https://github.com/elixir-lang/ex_doc/releases)
- [Changelog](https://github.com/elixir-lang/ex_doc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elixir-lang/ex_doc/compare/v0.28.3...v0.28.4)

---
updated-dependencies:
- dependency-name: ex_doc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-19 13:15:59 -04:00
Mitchell Hanberg c8d3f446b0 Remove last remnants of Phoenix 2022-04-20 00:05:27 -04:00
Mitchell Hanberg 016e761346 Remove comment from README 2022-04-20 00:03:38 -04:00
Mitchell Hanberg 79fb98a722 Remove phx generator templates 2022-04-20 00:00:11 -04:00
Mitchell Hanberg f942817994
Utilize the EEx Engine instead of creating an EEx string (#177) 2022-04-19 23:56:46 -04:00
dependabot[bot] ece4cb8a26
Bump ex_doc from 0.24.2 to 0.28.3 (#174) 2022-03-23 08:44:44 -04:00
Mitchell Hanberg ec484bcef6
Delete FUNDING.yml 2021-11-22 10:03:06 -05:00
dependabot[bot] d8a19a20cc
Bump phoenix_live_view from 0.16.1 to 0.17.5 (#158)
Bumps [phoenix_live_view](https://github.com/phoenixframework/phoenix_live_view) from 0.16.1 to 0.17.5.
- [Release notes](https://github.com/phoenixframework/phoenix_live_view/releases)
- [Changelog](https://github.com/phoenixframework/phoenix_live_view/blob/master/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix_live_view/compare/v0.16.1...v0.17.5)

---
updated-dependencies:
- dependency-name: phoenix_live_view
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-22 08:54:13 -05:00
Mitchell Hanberg 9b4dc26a5d Update elixir/erlang versions in CI workflow 2021-08-29 18:17:55 -04:00
Mitchell Hanberg c6d29e592b Bump v0.8.0 2021-08-29 18:11:24 -04:00
Mitchell Hanberg c965048f40
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.
2021-08-29 17:45:07 -04:00
Mitchell Hanberg 87ddbaa6b5
Update README.md 2021-07-26 22:22:08 -04:00
Mitchell Hanberg 0715a514c5 Bump v0.7.0 2021-06-27 12:05:45 -04:00
Mitchell Hanberg d9f00e5147
Class object syntax (#140)
* Class object syntax

Allows for conditionally setting classes on an element.

* Docs for class bindings
2021-06-27 12:04:19 -04:00
Mitchell Hanberg 9d05f74cdf
Properly emit boolean attributes (#139)
* Update some docs

* Properly emit boolean attributes.

* Account for quoted literals when compiling attributes

* Update changelog
2021-06-26 21:47:21 -04:00
Mitchell Hanberg d307fe35de
Update dependabot.yml 2021-06-15 14:11:10 -04:00
dependabot-preview[bot] 68a1d5fdac
Upgrade to GitHub-native Dependabot (#123)
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-06-15 14:10:26 -04:00
dependabot-preview[bot] f79464dcde
Bump phoenix_live_view from 0.13.3 to 0.15.7 (#131)
Bumps [phoenix_live_view](https://github.com/phoenixframework/phoenix_live_view) from 0.13.3 to 0.15.7.
- [Release notes](https://github.com/phoenixframework/phoenix_live_view/releases)
- [Changelog](https://github.com/phoenixframework/phoenix_live_view/blob/v0.15.7/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix_live_view/compare/v0.13.3...v0.15.7)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-06-15 14:08:06 -04:00
Mitchell Hanberg fb5f0a99f4 Bump v0.6.2 2021-06-03 23:14:58 -04:00
Mitchell Hanberg 540692f7cd Void elements can be compiled with no attrs 2021-06-03 23:13:06 -04:00
Mitchell Hanberg 49ebe8c603 update readme 2021-05-26 10:11:08 -04:00
Mitchell Hanberg 006886fa5e Bump v0.6.1 2021-05-23 14:01:25 -04:00
Mitchell Hanberg 15a999d8f3 Only collect slots in the root of a component
slot definitions in a component instance can only exist in the root of
that component, with root being defined as the lexical scoping of the
slot still being the component it's defined in.

Fixes #126
2021-05-23 13:56:05 -04:00
Mitchell Hanberg 978df64ffe Update version in readme 2021-05-22 01:20:42 -04:00
Mitchell Hanberg 301963f06b Bump v0.6.0 2021-05-22 01:13:58 -04:00
Mitchell Hanberg 99de9ad137
Update README.md 2021-05-21 10:50:31 -04:00
Mitchell Hanberg b2bd06d037 Add some docs 2021-05-13 21:28:15 -04:00
Mitchell Hanberg 3b00fedb27 update version in readme 2021-05-13 20:56:40 -04:00
Mitchell Hanberg 0b55cf1cec Bump v0.6.0-rc.1 2021-05-13 00:31:00 -04:00
Mitchell Hanberg 5150a93e38 emit live view compatible component and slot markup
- requires the development branch of live_view currently, if you are
  going to be using live view

ci

Docs

Raise minimum elixir version to 1.9

There is some bug in EEx that was fixed in 1.9 and I can't be bothered
to make it backwards compatible with the bug.

ugh

Remove commented out line
2021-05-13 00:21:43 -04:00
Mitchell Hanberg 73b6973a74 Boost minimum tested version to 1.9
Add erlang 22
2021-05-13 00:21:43 -04:00
Mitchell Hanberg 851f6415fe Slots!
Integration test for slots

Format integration test project

Hide slots assign in temple prefixed key

Won't compile temple related assigns when calling Utils.runtime_attrs

Update component docs with slots usage
2021-05-13 00:21:43 -04:00
Mitchell Hanberg f7197ede4a Update readme with goals 2021-05-13 00:21:43 -04:00
Mitchell Hanberg 074241be4e Rename Temple.EEx to Temple.Generator 2021-04-11 17:27:02 -04:00
Mitchell Hanberg 07a1d5d451 Rename ast properties to align with given ast
The properties were either not needed at all, or were named back when
there was only one node type. now that each node is it's own struct,
they really don't need to share any common properties.
2021-04-10 11:08:06 -04:00
Mitchell Hanberg d40ff3e0b1 Allow components to be used with inline blocks
Fixes #116
2021-04-09 00:28:52 -04:00
Mitchell Hanberg fe3aed5df7 Some cleanup 2021-04-09 00:16:30 -04:00
Mitchell Hanberg b35b9b6d91 Rename a dir and shrink the test matrix 2021-04-09 00:16:30 -04:00