use Template Toolkit for plain .html files? - html

Right now I have a site that uses Perl and Template Toolkit (using the Template module) for pages that require calculation and/or database access but regular HTML files for the the rest of the pages. However, I have discovered that it would be nice if I had access to templating goodness for even the "plain HTML" pages, if only for the convenience of "including" standard headers and footers, etc.
What is the easiest way to introduce this with the least amount of disruption to the current site? (i.e. I would prefer not to have to change all the filenames and links).

The two approaches that spring to my mind are:
Process the static files off-line using ttree
Write some sort of mod_perl hander to run all .html files through TT before outputting

Related

Generate MkDocs pages in the browser

Is it possible to generate the pages for MkDocs dynamically/on-the-fly in the browser using JavaScript? In this case, the build process incl. all the required tools would not be necessary any longer. Since the build process generates static pages, I assume that generally this is possible, but haven't found any related information.
No this is not possible. McDocs is written in the Python Language, not Javasript. Page builds can only be run from the command line.

How to template HTML code and use that across multiple HTML files?

Not sure whether this is the best place for this question.
Is there a way to template a block of HTML code and then reuse it across multiple HTML files.
I know you can do it with PHP include.
But what is the industry standard now?
I have heard of Handlebars and Moustache. Are these the tools for this purpose?
And what is Jekyll and Middleman trying to do? What is static site generator?
Refer back to the above problem, which will solve my problem?
There are a number of templating engines these days that you can use. Mustache and Handlebars are both templating libraries with ports in different languages. There are a number of other templating engines: http://en.wikipedia.org/wiki/Comparison_of_web_template_engines
The library to use depends on your needs. Mustache emphasizes logic-less templates. This means that you should try and minimize the number of conditional statements (if/else) in your templates. Often, conditional if/else are used for determining what to render. Other libraries like Handlebars allow for logic. Choosing the right library will come down to the application requirements, how you want to use your templates, who will be maintaining them, and perhaps the language(s) that you are using for your application.
Jekyll, Middleman, Pelican and other static site generators use templating engines to help you generate a static site. When you write themes for these systems, you write the templates for the theme in the designated templating engine's syntax. For example, Jekyll uses the Liquid templating engine, and Pelican uses Jinja2. Static site generators started as a way to reduce the complexity of data management in blogs and websites. With some other blogging platforms, your posts and content would be stored in a database. This made migrating your work and backing it up a bit more complex, especially if you did not have in-depth technical knowledge of the blogging platform that you use. With static site generators, you can write all of your content in a text editor, using a simple file format like Markdown. To create a website, you just have to configure the system using a basic conf file, and follow the suggested project structure.
After writing your content, the static site generating system has the capability to automatically builds your website folder for you, making deployment easier. This is usually done through some kind of script/automation. All of your content is built into static .html and .css files (.js and image files as well, if you have them). This also can improve page load speed, since a static resource can be cached by the browser, and there are not as many operations on the server happening for each page request.
Using a static site generator will also help you configure how you manage content. A templating engine will be more for how you render content. Since rendering content is a subset of how you manage content, most static site generators will come packaged with a templating engine.

Creating HTML according to files existence in the file system

I am writing a web application (I am a newbie), where the markup is created by XSL and XML transformations and the style is declared by css files and also some use of JavaScript. I need to create a web page that part of its content is the information on files in a specific directory in the file system.
Any ideas?
Are you talking about the client's file system, or the server's?
If the client's, what you are asking is basically impossible for security reasons without some specific browser plugins/extensions (like a java applet with the right access) - you probably don't want to get into that.
If you are talking about the server file system, you will need some sort of server side language to read the file(s) and return them to browser requests. The sort of things that do that are PHP, ASP.NET, Ruby on Rails, etc...also look into Server Side Includes - that may be sufficient for your needs.
Do you mean the client's filesystem or the server's filesystem? If it's the client's, these tools are inadequate (as access to the client's OS is severely restricted for security purposes). I think most people go with a Java applet for stuff like that.

Languages / Libraries / Modules for building a "template builder" web application?

My company builds websites for membership-based associations. We currently use custom DLL's (written in CodeGear Delphi) which interact with a SQL Server database and use a custom HTML-based template language. Basically we build templates in HTML / CSS / Javscript with the dynamic parts being generated by tags in the format <#TAG NAME>.
I've been building all the templates for our clients using Dreamweaver, but my boss wants me to create a web tool which our clients can use to visually build templates themselves in our format, without needing to do actual HTML coding. For example, they would go to our site and say "create profile update form" which would generate an HTML skeleton, then they could select functions such as "add form field" to generate the correct HTML for that field based on the options they enter. The template would then be saved to the web server as an HTML file (or to the database as a blob) and used by the DLL's to generate pages on the site. They should also be able to re-visit the existing templates to edit them, and manually edit the HTML if necessary for advanced customization.
Obviously there are a lot of ways to go about this. I'd like suggestions on a server-side language (and hopefully associated libraries / modules) which is capable of building and parsing HTML documents and writing these to the file system. The tool needs to be IIS compatible, and preferably in a C-style syntax. I'm very proficient in Javascript and Perl, slightly less so in C++ and Java, and have no experience with PHP, Ruby, or Python (though I'm willing to put in the time to learn if they are the best tool for the job!).
Thanks for your suggestions!
Have you seen TinyMCE? It lacks form editing, but you could easily build plugins to customize it to your needs and create the front-end around it. For server side you can use any language that you like. Basically all you would need to do is to save the HTML templates that your customers would create to a database.
I used mobirise4 and it works for me, there are lots of templates to start with, even some components, and BootStrap studio its the best payed desktop application, you can literally build a website with some drag & drops, it lets you to edit code too.

Convert Sandcastle Help File Builder Output (Web site) to MediaWiki format

I need to
convert my Sandcastle Help File
Builder (SHFB) output that is a Web
site (HTML) to Media wiki format
Find a way to transfer/include the
converted pages directly into the
MediaWiki we have set up.
Any ideas? we have over 1000 pages of HTML files inthe Website (output of SHFB).
I thought of using a html2wiki converter ..I could think of looking around for a script to convert those 1000 pages into wiki format... that could take care of (1).
But I would still be left with the block in the last bit of the pipeline - how to feed converted pages directly into the Wiki?
Take a look at Help Server. It allows to publish .CHM / .HxS produced by any tool (including Sandcastle) on the web and provides URL-based integration API.
We use MediaWiki as well. A set of templates for it allows us to create links to class reference shared by Help Server. Some examples of such links can be found right on that page.
Note that DataObjects.Net Help web site is running on Help Server 2.X, but the newest one is 3.X (example web site is here).
I did some work with ingesting existing material from several sites into a comprehensive Wiki. It did not involve Sandcastle, but if you're dealing with HTML it shouldn't matter much. html2wiki extensions are out there, and from what I have read they can solve a lot of problems. I needed a little more control over each node in the DOM, so i used Simple HTML DOM Parser. It's in PHP and was easily dropped into Mediawiki's includes.
For creating the new pages, I ended up writing a small script that uses Mediawiki's Article class, specifically the doEdit function. this allows you to create new articles programatically, without user interaction. Of course, you'd want to be careful with this... The last thing you need is to create 1000 pages that are no good and have to be deleted. But perhaps this will help get you going.