Closed olliekyan closed 10 years ago
The code
helper has no way to know from ERb how indented it is. Just indent the block inside your helper exactly as much as you want it indented in the output.
I'm doing that, what I really need the helper to do is strip the leading/trailing whitespace before and after the code within the helper as currently it keeps this if I want my document formatting to be consistent. e.g. this is my document structure (I'll use an example that has more lines)
And this is the output from the helper...
The only way I can get it to respect ignoring the leading/trailing whitespace is to align my code helper block all left like this...
and then I get the correct output...
I just wondered if there was an easy fix to strip this whitespace out? I can use the left formatted code blocks as it's not a deal breaker, it would just be nice to keep all my code formatted correctly. I tried passing the block within a another helper and gsub the whitespace but it was stripping the CSS classes.
Thanks for the great extension btw, so handy for pattern libraries :+1:
Yeah, you need to left-align it like that. ERb is not indentation-aware. If you love indentation, use Haml - it'll work fine.
Ah okay cool, no problem. Thanks for replying.
I'm not sure why this is happening, and I can't find a workaround. I'm trying to put code examples into erb files but it's preserving my space indentation (2 spaces) within the code block. e.g. this...
Is showing as
But if I remove all my indentation the examples work properly (although everything is left aligned so it doesn't make for very nice code examples), any ideas? Does it only work when using markdown files and not in erb templates?