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

ECR render at runtime #4194

Closed
faustinoaq opened this issue Mar 26, 2017 · 3 comments
Closed

ECR render at runtime #4194

faustinoaq opened this issue Mar 26, 2017 · 3 comments

Comments

@faustinoaq
Copy link
Contributor

faustinoaq commented Mar 26, 2017

Hi i'm using Kemal and I have to recompile files each time html change in ecr files.

Would be posible that ECR return a string with html changes rendered without recompile?

Actually ECR do this:

# greeting.ecr
# Greeting, <%= name %>!

require "ecr/macros"

name = "World"

io = IO::Memory.new
ECR.embed "greeting.ecr", io
io.to_s # => "Hello World!"

# Output:
# io << "Hello "
# io << name
# io << "!"

Would be possible do something like this:

# greeting.ecr
# Greeting, <%= name %>!

require "ecr/render"

name = "World"
puts ECR.render "greeting.ecr", name

# Output
# Greeting, World!

An useful use-case would be render in Kemal (see: kemalcr/kemal/issues/335)

@bew
Copy link
Contributor

bew commented Mar 26, 2017

To follow your idea, I think ECR.render should render at runtime, and ECR.render! should render at compile time

@ysbaddaden
Copy link
Contributor

You want a safe templating language, one where the logic is interpreted at runtime, thus reloadable, since you can reload, reparse and reinterpret (at least in non release mode).

But ECR allows any Crystal code, which must be compiled, and it can't reload templates at runtime.

@faustinoaq
Copy link
Contributor Author

@ysbaddaden ok, Mustache(Crustache) and Liquid shards are templating languages like you said.
Maybe, could be good a shard for a template language based on ECR syntax 😅

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

No branches or pull requests

3 participants