Slang doesn't render anymore
renich opened this issue · comments
Description
I dunno what changed in v1.1.1 but, since then, slang doesn't render. No error either.
Steps to Reproduce
- Use kemal v1.1.1
- Try rendering some slang.
Expected behavior: [What you expect to happen]
I would expect slang to be rendered and get some html.
Actual behavior: [What actually happens]
I get the slang source code.
Reproduces how often: [What percentage of the time does it reproduce?]
Every time.
Versions
[renich@introdesk myapp]$ shards
Resolving dependencies
Fetching https://github.com/kemalcr/kemal.git
Fetching https://github.com/luislavena/radix.git
Fetching https://github.com/jeromegn/kilt.git
Fetching https://github.com/crystal-loot/exception_page.git
Fetching https://github.com/sija/backtracer.cr.git
Fetching https://github.com/jeromegn/slang.git
Using radix (0.4.1)
Using kilt (0.6.1)
Using backtracer (1.2.1)
Using exception_page (0.2.2)
Using kemal (1.1.0 at 523340b)
Using slang (1.7.3 at 901df64)
[renich@introdesk myapp]$ crystal version
Crystal 1.3.2 (2022-01-18)
LLVM: 13.0.0
Default target: x86_64-redhat-linux-gnu
Running on Fedora 35.
Additional Information
It seems that you removed kilt and that caused the issues. The following shard.yml file will not be sufficient in v1.1.1:
name: myapp
version: 0.1.0
license: MIT
authors:
- Renich Bon Ćirić <renich@woralelandia.com>
description: |
App de ejemplo.
dependencies:
kemal:
github: kemalcr/kemal
tag: v1.1.1
slang:
github: jeromegn/slang
tag: v1.7.3
It does work with v1.1.0 though.
This is because kilt
has been removed as a dependency of kemal
(#467).
If you want to use it, you need to add it as a dependency to your shard.yml
.
See https://github.com/jeromegn/kilt#Installation for instructions.
Related to #629
@straight-shoota so I did. The result is me geetting the slang markup being spat to back to me.
Here's a minimal example:
#!/usr/bin/env bash
# create app
crystal init app kemal-test
cd $_
# main
cat << EOF > src/kemal-test.cr
require "kemal"
require "kilt"
require "kilt/slang"
get "/" do
render "src/views/index.slang"
end
Kemal.run
EOF
# my view
mkdir -p src/views
cat << EOF > src/views/index.slang
doctype html
html
head
meta name="viewport" content="width=device-width,initial-scale=1.0"
title This is a test
body
h1 Hello, world!
EOF
# add shards
cat << EOF >> shard.yml
dependencies:
kemal:
github: kemalcr/kemal
kilt:
github: jeromegn/kilt
slang:
github: jeromegn/slang
EOF
# install shards
shards install
# try out
crystal run src/kemal-test.cr
btw, I didn't mean the "spitting" part as a bad thing. I'm a spanish native speaker and that's how we say it.. hehe `:)
You have to use Kilt.render
instead of kemal
's render
method.
Ah... OK. Oh well. That's sad...
Thanks.
Alternatively, you can of course override kemal
's render
with an implementation that delegates to Kilt.render
as it was before #618. The only difference is that this implementation won't be implicitly provided by kemal.
Of course. Thank you.
For what is worth, this actually works:
# create app
crystal init app kemal-test
cd $_
# main
cat << EOF > src/kemal-test.cr
require "kemal"
require "kilt"
require "kilt/slang"
macro render(filename, layout)
__content_filename__ = {{filename}}
content = render {{filename}}
render {{layout}}
end
# Render view with the given filename.
macro render(filename)
Kilt.render({{filename}})
end
get "/" do
render "src/views/index.slang"
end
Kemal.run
EOF
# my view
mkdir -p src/views
cat << EOF > src/views/index.slang
doctype html
html
head
meta name="viewport" content="width=device-width,initial-scale=1.0"
title This is a test
body
h1 Hello, world!
EOF
# add shards
cat << EOF >> shard.yml
dependencies:
kemal:
github: kemalcr/kemal
kilt:
github: jeromegn/kilt
slang:
github: jeromegn/slang
EOF
# install shards
shards install
# try out
crystal run src/kemal-test.cr
FYI. I created a shard kemal-kilt which restores removed functionality.
Thank you @mamantoha 🙏