Created
June 10, 2013 21:02
-
-
Save miketheman/5752267 to your computer and use it in GitHub Desktop.
erb relative inclusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ erubis outer-template.erb | |
| bash -x -c ' | |
| echo $(date +%s) > /tmp/test-templates | |
| echo "this is an outer template" >> /tmp/test-templates | |
| ' | |
| bash -x -c ' | |
| echo "This is an inner template" >> /tmp/test-templates | |
| echo "Some inner ruby: 25" | |
| ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bash -x -c ' | |
| echo "This is an inner template" >> /tmp/test-templates | |
| echo "Some inner template ruby math results: <%= 5 * 5 %>" | |
| ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bash -x -c ' | |
| echo $(date +%s) > /tmp/test-templates | |
| echo "this is an outer template" >> /tmp/test-templates | |
| ' | |
| <% | |
| def import(fname) | |
| eruby = Erubis::Eruby.new | |
| here = Pathname.new(__FILE__).dirname.realpath | |
| input = File.read(File.join(here, fname)) | |
| src = eruby.convert(input) | |
| eval src | |
| end | |
| -%> | |
| <%= import('inner-template.erb') %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment