Routing and Template Cookbook: BML Conversion Workflow

From Dreamwidth Notes
Jump to: navigation, search

This describes the basic workflow for translating a BML file into the new Template Toolkit system.

Workflow Steps

Move the BML file out of the way

Your new view/controller won't work if the BML file is still present. Because you'll need to reference the BML file during coding, it is easiest to move the BML file out of the way somewhere--into a specific directory you have for that purpose, or renamed to have old at the end of the name, etc.

Set up the routing, controller and view

Using instructions in the Basic routing, handlers, and templates, set up an equivalent routing URL, a controller handler function, and a view template to the old BML page.

Remember to restart apache whenever you make any changes to Perl files in order for those changes to show up on the server!

Move the old associated bml.text to the view template

In order for the template to have access to the ML strings, you will need to move the old associated bml.text file into a tt.text file. Then, you'll need to run the database update script to update all the translation strings in the database.

Get the view rendering with just the title

To check and see that the routing, controller, and view all are working okay together, try to get the page to render with just the title.

Start transferring over code from the BML to the controller function

In chunks, start to transfer the BML code to the controller function. Start working at separating it into Perl logic code that constructs variables that the template then uses, and put the HTML parts into the template, translating simple display logic into Template Toolkit directives. Keep doing this until all the BML code is accounted for!

Test!

Try to test the different logic paths that you have translated and confirm that the page still functions correctly.

Examples