Difference between revisions of "Routing and Template Cookbook: BML Conversion Workflow"

From Dreamwidth Notes
Jump to: navigation, search
m (Move the BML file out of the way: Tyop)
(adding an example)
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
  
 
Using instructions in the [[Routing and Template Cookbook: Basic routing, handlers, and templates|Basic routing, handlers, and templates]], set up an equivalent routing URL, a controller handler function, and a view template to the old BML page.
 
Using instructions in the [[Routing and Template Cookbook: Basic routing, handlers, and templates|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 ==
 
== Move the old associated bml.text to the view template ==
Line 26: Line 28:
  
 
Try to test the different logic paths that you have translated and confirm that the page still functions correctly.
 
Try to test the different logic paths that you have translated and confirm that the page still functions correctly.
 +
 +
= Examples =
 +
 +
* Static pages and a simple example: https://github.com/dreamwidth/dw-nonfree/pull/113/files
  
 
[[Category: Routing and Template Cookbook]]
 
[[Category: Routing and Template Cookbook]]

Latest revision as of 14:55, 13 June 2016

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