Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Interpolate HTML files with Toolips Components and values.

License

Notifications You must be signed in to change notification settings

ChifiSource/ToolipsInterpolator.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


dead repo

ToolipsInterpolator is now a part of Toolips 0.3 itself. Toolips?.

  • ( This project can still be used with Toolips 0.2. )

The interpolator extension provides a single Toolips.Servable, the InterpolatedFile. This can be read from a directory, and is provided arguments to determine what to replace variable names with. Variable names are denoted with a $, much like in regular Julia.

index.html
<h1>Toolips interpolator example</h1>
<p>$xis is the number</p>
<h3> This should be a p:</h3>
<div align="center">
$helloworld
</div>
$mybutt
$regdiv
$myval
MyApp.jl
module MyApp
using Toolips
using ToolipsInterpolator
# welcome to your new toolips project!
"""
home(c::Connection) -> _
--------------------
The home function is served as a route inside of your server by default. To
    change this, view the start method below.
"""
function home(c::Connection)
    newp = p("helloworld", text = "hello world!")
    myx = 5
    mybutt = button("mybutt", text = "my button!")
    regdiv = div("regdiv")
    myval = "what the heck"
    intfile = InterpolatedFile("src/index.html", xis = myx, myval = myval,
    regdiv, mybutt, newp)
    write!(c, intfile)
end

fourofour = route("404") do c
    write!(c, p("404message", text = "404, not found!"))
end

routes = [route("/", home), fourofour]
extensions = Vector{ServerExtension}([Logger(), ])
"""
start(IP::String, PORT::Integer, ) -> ::ToolipsServer
--------------------
The start function starts the WebServer.
"""
function start(IP::String = "127.0.0.1", PORT::Integer = 8000)
     ws = WebServer(IP, PORT, routes = routes, extensions = extensions)
     ws.start(); ws
end
end # - module

About

Interpolate HTML files with Toolips Components and values.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages