Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Time Macros #2

Open
shadowtime2000 opened this issue Dec 11, 2020 · 3 comments
Open

Compile Time Macros #2

shadowtime2000 opened this issue Dec 11, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@shadowtime2000
Copy link
Contributor

Currently the l function is called on runtime and generates the HTML string on the fly. I want this package to be able to be used as a way to structure writing pure HTML strings, so it may be cool to have some compile time macros which compile l() calls straight into the HTML string. We could use babel-plugin-macros or SweetJS, but I believe Sweet is no longer maintained. We could first only compile l() calls that use constants as parameters and later compile with variables too.

@shadowtime2000 shadowtime2000 added the enhancement New feature or request label Dec 11, 2020
@shadowtime2000
Copy link
Contributor Author

shadowtime2000 commented Dec 11, 2020

Example of such compilation:

In:

const elem = l("div", {}, [
	"Foo",
	l("button", {}, "Bar")
])

Out:

const elem = `<div>
	Foo
	<button>Bar</button>
</div>`

In:

const btn = ({ theme, text }) => l("button", { className: `btn btn-${theme}` }, text);

Out:

const btn = ({ theme, text }) => `<button class="btn btn=${theme}">${text}</button>`;

@shadowtime2000
Copy link
Contributor Author

This would probably require a luciascript.macro or babel-plugin-luciascript package. @aidenybai Thoughts on that?

@aidenybai
Copy link

Yes, that sounds great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants