diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 15:55:06 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 15:55:06 -0700 |
commit | fcdb12f4caaa69524cd0e33068b6743af62d79fd (patch) | |
tree | 3d55efb2f052cd2f39a69f0ea34425c658406fce | |
parent | 2d29121e2e6a49912cd5e635974737d1002b6d3e (diff) | |
download | gitbook-fcdb12f4caaa69524cd0e33068b6743af62d79fd.zip gitbook-fcdb12f4caaa69524cd0e33068b6743af62d79fd.tar.gz gitbook-fcdb12f4caaa69524cd0e33068b6743af62d79fd.tar.bz2 |
Set size of exercise code editor according to solution
Use the number of lines in solution to set editor’s size
-rw-r--r-- | lib/generate/template.js | 4 | ||||
-rw-r--r-- | templates/includes/book/exercise.html | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/generate/template.js b/lib/generate/template.js index 808217a..e29464c 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 8b1fd1f..5d721f9 100644 --- a/templates/includes/book/exercise.html +++ b/templates/includes/book/exercise.html @@ -12,7 +12,7 @@ <div class="message"> {% autoescape false %}{{ section.content }}{% endautoescape %} </div> -<div class="editor" style="height: {{ section.content.split("\n").length*20 }};">{{ section.code.base }}</div> +<div class="editor" style="height: {{ section.code.solution|lines*20 }}px">{{ section.code.base }}</div> <pre class="hidden code-solution">{{ section.code.solution }}</pre> <pre class="hidden code-validation">{{ section.code.validation }}</pre> |