Download Now, Ask Questions Later (Linux amd64)
What is Vorlage?
Vorlage is an HTTP server and HTML processor that keeps the
frontend development as basic and as simple as possible while
keeping the backend as flexible and as powerful as
possible.
Its aim is to stop the unhealthy co-dependence of frontend
and backend so that users of Vorlage are not restricted to a
particular framework, paradigm, and/or language when building
new or maintaining existing web applications.
Vorlage used in reporting/analytics.
The Vorlage architecture took into account the popular use
of the web to format reports/analytics. After all, that's why
HTML was made in the first place. So Vorlage users will find
that the processing and formatting of data in HTML form is
fast, powerful, efficient, and intuitive.
Vorlage used in processing of input.
Vorlage users will find that taking in input is easier than
ever. Vorlage forces backend developers to document their
inputs and outputs to their form processors, RESTful APIs,
ect. This gives frontend developers a clear-cut and concise
experience.
Simply put, Vorlage forces everyone to be very deliberate
with their methods handling input and output.
Vorlage used in basic websites.
Even though Vorlage is powerful when it comes to
high-demand, high-volume, high-processing traffic, Vorlage is
engineered to also work great with small, basic
websites. Vorlage start ups instantly and requires no external
dependencies/external installations and is super
lightweight.
Learn By Example
This article you'll go through some simple steps to see
Vorlage in practice. It's easy to understand so just follow
along and read the additional details if you so desire. But
you should be focusing on the code/HTML itself to easily
comprehend Vorlage's capabilities.
Write a header.
header.html
As you can tell we've set the title to a variable. This
header will be used across multiple pages, but the title of
each one of those pages will change. So we use a variable that
we can define in the page itself.
Write a footer.
footer.html
The footer here is just closing the tags that the header
had opened. Simple and sweet.
Write a web processor.
myproc.go
func MyIP() string {
return getRemoteIP()
}
You can make "Processors" in Vorlage. Processors can supply
variables to the page without using the #define
macro. Here, our processor (myproc
) sets a
variable ($(myproc.MyIP)
) to print out the
IP of the requester.
Finally, write the index.
index.html
#prepend header.html
#append footer.html
#define $(MyName) Kevin
#define $(Title) Home Page
<p>Hello, my name is $(MyName).</p>
<p>My IP is $(myproc.MyIP)!</p>
This is where it certainly all comes together. Look closely
at what's going on here. Note that
even though $(Title)
is declared
after the header.html is prepended, it will still be defined
in header.html by the time the page is outputted.
Also note that the macros
(#prepend
, #append
, #define
,
ect) are at the start of the page: this is required. All
macros must be defined at the top of any file to make it
impossible to mix the Vorlage processing with the actual
HTML. This is an effort to make Vorlage easy to work with for
those who are not skilled in logical text (aka
programming).
And now, the output:
<html>
<head>
<title>Home Page</title>
</head>
<body>
<p>Hello, my name is Kevin.</p>
<p>My IP is 127.0.0.1!</p>
</body>
</html>
This is what the requester will see. A single,
well-put-together html page with variable information.