The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
{%- for article in articles if article.published %}
<div class="article">
<h2><a href="{{ article.href|e }}">{{ article.title|e }}</a></h2>
<p class="meta">written by <a href="{{ article.user.href|e
}}">{{ article.user.username|e }}</a> on {{ article.pub_date|dateformat }}</p>
<div class="text">{{ article.body }}</div>
</div>
{%- endfor %}
Kinda. I think it's constant above that is broken:
require "ecr"
ECR_ROOT = "./src/template/components/ecr"
class Greeter
def initialize(@name : String)
end
ECR.def_to_s "#{ECR_ROOT}/greeter.ecr"
end
pp! ECR_ROOT
pp! Greeter.new("John").to_s # => "Greetings, John!\n"
Gives:
There was a problem expanding macro 'embed'
Code in macro 'def_to_s'
2 | ECR.embed "#{ECR_ROOT}/greeter.ecr", "__io__"
^
Called macro defined in /usr/local/Cellar/crystal/1.0.0/src/ecr/macros.cr:69:3
69 | macro embed(filename, io_name)
Which expanded to:
> 1 | {{ run("ecr/process", "#{ECR_ROOT}/greeter.ecr", "__io__") }}
^--
Error: Error executing run (exit code: 1): ecr/process '"./src/template/components/ecr"/greeter.ecr' __io__
stderr:
Error opening file with mode 'r': '\"./src/template/components/ecr\"/greeter.ecr': No such file or directory
.
is the dir you're executing the file from while __DIR__
is the location of the file or something like that
ECR.def_to_s "#{ECR_ROOT.id}/greeter.ecr"
.id
?
.id
returns the raw value of the constant, e.g. ./src/template/components/ecr