PencilCode/pencilcode-site — pull request #66 by davidbau (2014-04-11 13:33:35+00:00)
Title: Template support

This pull request will start integrating James and Karen and Eric's implementation of templates. Below I'll start a discussion on the design.

Here is how it currently works (email from James): an activity directory contains either a file called "wrapper" (coffeescript, wrapped again by standard wrapper) or "wrapper.html" (entire file, no additional wrapper). The directory may optionally contain an "instructions.html" file, which is displayed above the editor.

The wrapper file (either name) should have a single block of lines that contain the default student text, with delimiters at the start and end, shown in red.

#{{start-default-text;indentBy=0}}
canISleepIn = (isWeekday, isVacationDay) ->
# Change so that canISleepIn returns false only on school
# days, and returns true otherwise.
return false
#{{end-default-text}}

The ";indentBy=0" is an optional argument (not yet fully supported), intended to make it easy to have code indented when executed, but not indented when the student is editing (i.e. so that the "canISleepIn" line in the example above could be outside the default code).

The delimiters {{start-default-text}} and {{end-default-text}} may appear anywhere on the line (e.g. before or after comment markers); the entire line containing the delimiter will be removed when producing the code to be executed.