From fcdb12f4caaa69524cd0e33068b6743af62d79fd Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Mon, 31 Mar 2014 15:55:06 -0700 Subject: [PATCH] Set size of exercise code editor according to solution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the number of lines in solution to set editor’s size --- lib/generate/template.js | 4 ++++ templates/includes/book/exercise.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/generate/template.js b/lib/generate/template.js index 808217a64..e29464c7a 100644 --- a/lib/generate/template.js +++ b/lib/generate/template.js @@ -6,6 +6,10 @@ var parse = require("../parse"); var fs = require('./fs'); +swig.setFilter('lines', function(content) { + return content.split('\n').length; +}); + // return a templeter for page var initTemplate = function(options) { var tpl = swig.compileFile(path.resolve(__dirname, '../../templates/page.html')); diff --git a/templates/includes/book/exercise.html b/templates/includes/book/exercise.html index 8b1fd1f6f..5d721f983 100644 --- a/templates/includes/book/exercise.html +++ b/templates/includes/book/exercise.html @@ -12,7 +12,7 @@
{% autoescape false %}{{ section.content }}{% endautoescape %}
-
{{ section.code.base }}
+
{{ section.code.base }}