kemalcr / kemal

Fast, Effective, Simple Web Framework

Home Page:https://kemalcr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slang layout doesn't render the content as HTML

zolomatok opened this issue · comments

Description

When doing...

get "/" do
    render "src/challenge/pages/home.slang", "src/challenge/pages/layouts/main.slang"
end

...the content gets rendered as text, literally <h1>Hello</h1>, instead of actual HTML.
If the layout is written in ECR, it works. (Even if the view remains slang.)


main.slang:

html
    body
        =content

home.slang:

h1 Hello

the entire project:

require "./challenge/*"
require "kemal"
require "kilt/slang"

module Challenger
  
    get "/" do
        render "src/challenge/pages/home.slang", "src/challenge/pages/layouts/main.slang"
    end
    
    Kemal.config.port = 6969
    Kemal.run

end

Versions

Crystal 0.35.1 (2020-06-19)
LLVM: 10.0.0
Default target: x86_64-apple-macosx
macOS Catalina, 10.15.3

Hi @zolomatok .

This is not Kemal issue.

Difference between single and double equals in Slang (= vs ==)

  • = inserts HTML with escaped characters
  • == inserts HTML without escaping. It is needed when you have already rendered HTML and you need to insert it to your layout directly.

You should use == in your case.

Thank you very much for your help @mamantoha !
It works. Is there Slang doc I don't know about? :O
This is not mentioned on the GitHub page.

It's not mentioned in README. I've already created a PR to fix this jeromegn/slang#56

Super cool, thank you very much!