GithubHelp home page GithubHelp logo

koreander's People

Contributors

frosner avatar lukasjapan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

koreander's Issues

Koreander templates are not rendered via SpringBoot and fat JARs

I am currently using Spring 5 and Koreander as the template engine. I am unfortunately getting a java.lang.ArrayIndexOutOfBoundsException: Index 10912 out of bounds for length 10912] error, at de.cvguy.kotlin.koreander.Koreander.compile(Koreander.kt:62) ~[koreander-0.1-WIP.jar:na].

I am using a fat JAR, which requires the Kotlin compiler to be unpacked at startup, via:

bootJar { requiresUnpack '**/kotlin-compiler-*.jar' }

My Spring application looks like:

@SpringBootApplication class TestApplication { @Bean fun koreanderViewResolver(): ViewResolver = KoreanderViewResolver() }

And the corresponding controller:

@Controller class DemoController { @GetMapping("/demo") fun demo(): String { return "example" } }

I'm using compile "de.cvguy.kotlin:koreander-spring:0.+" via Gradle.

Unable to create HTML 5 template

1. Reproducable example:

  • Create main.kt and put following code:
    fun main() {
        val kor = javaClass.getResource("/index.kor").readText()
        Koreander().render(kor, Any())
    }
  • Create index.kor in resource directory in src/main folder of project and put the following code:
    !!! 5
    %html
        %head
        %body
            %p.hello Hello World!
    

2. Expected result:

Expected to see the <!DOCTYPE html> declaration instead of the exception.

3. Actual result:

de.cvguy.kotlin.koreander.exception.UnexpectedDocType: Parse error in tba at 0:4 - Unexpexted DocType 5 exception thrown

4. StackTrace:

de.cvguy.kotlin.koreander.exception.UnexpectedDocType: Parse error in tba at 0:4 - Unexpexted DocType 5
	at de.cvguy.kotlin.koreander.parser.KoreanderParseEngine.unshiftDocType(Parser.kt:169)
	at de.cvguy.kotlin.koreander.parser.KoreanderParseEngine.parse(Parser.kt:79)
	at de.cvguy.kotlin.koreander.parser.KoreanderParser.generateScriptCode(Parser.kt:17)
	at de.cvguy.kotlin.koreander.Koreander.compile(Koreander.kt:81)
	at com.github.animeshz.konvironment.http.RoutingKt$module$1$1.invokeSuspend(Routing.kt:27)
	at com.github.animeshz.konvironment.http.RoutingKt$module$1$1.invoke(Routing.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:273)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:141)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:161)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
	at io.ktor.routing.Routing.executeResult(Routing.kt:147)
	at io.ktor.routing.Routing.interceptor(Routing.kt:34)
	at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:99)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:273)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:141)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:161)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:118)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:273)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:141)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:161)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invokeSuspend(NettyApplicationCallHandler.kt:40)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:111)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at io.ktor.server.netty.NettyApplicationCallHandler.handleRequest(NettyApplicationCallHandler.kt:30)
	at io.ktor.server.netty.NettyApplicationCallHandler.channelRead(NettyApplicationCallHandler.kt:24)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:56)
	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:365)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518)
	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:834)

Head and p tags closing incorrectly

Heya Lukas,
The Japanese beers example from the readme seems to be closing the <head> tag incorrectly.
Rather than:

<!DOCTYPE html>
<html>
    <head>
        ...
    </head>
    <body>
        ...
    </body>
</html>

The generated HTML looks like (inspect the payload, not the HTML inspector in the browser):

<!DOCTYPE html>
<html>
    <head>
        ...
    <body>
        ...
    </body>
    </head>
</html>

I've observed a similar issue with %p tags that include a linebreak. For example:

!!! 5
%html
    %body
        %p
            line 1
            line 2
            line 3
        %div

Renders correctly, but introducing a linebreak in the paragraph:

!!! 5
%html
    %body
        %p
            line 1
            %br
            line 2
        %div

Instead results in:

<!DOCTYPE html>
<html>
    <body>
        <p>
            line 1
            <br>
            line 2
        <div></div>
        </p>
    </body>
</html>

Am I nesting the linebreak incorrectly in the paragraph or are there some inconsistencies in how the indentations are read?

Many thanks,
fish

Shortcut notation for assigning classes ignored

Heya Lukas,

Love the syntax, but I've ran into an issue with the shortcut notation for assigning classes.

According to the readme it should be possible to use %tag.myclass โ†’ <tag class="myclass"></tag>.
However, when parsing %span.test test span with test class the result is
<span.test>test span with test class</span.test> instead.

Would be awesome if you could try to replicate,
Many thanks in advance and a fantastic holiday season,
fish

template.kor:

!!! 5
%html
  %head
    %title Test title

  %body
    .test
      %p test div with test class
      %span.test test span with test class

app.kt:

data class Model(val name: String = "")

class app {
    fun generateHtml(): String {
        val viewUrl = javaClass.getResource("template.kor")
        return Koreander().render(viewUrl, Model())
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.