Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Thomas Leitner
RE: Variable copyright years [ reply ]  
2010-12-04 08:27
You just have a typo in your code: the variable is named "copyright" and not "copystr". So writing "<%= copyright %> just works fine (tested on a fresh webgen website with webgen 0.5.14).

-- Thomas

By: Markus Mayer
Variable copyright years [ reply ]  
2010-12-03 20:19
This is probably super easy to solve, but I can't quite get it right.

I want the copyright years in the footer to be dynamically generated. So, I have come up with some Ruby code in the template file that does almost all of that and it works. The problem is outputting the contents of the variable into the generated pages.

My code looks like this:

[...]
<div id="footer">
<%
baseyear = 2009;
year = Time.now.year;
copyright = baseyear.to_s;
if year > baseyear
copyright += " &ndash; #{year}";
end
%>
<p>&copy; <%= copystr %> My Company</p>
</div>
[...]

If I use <%= copystr %> in an attempt to output the contents of "copystr" into the page, I get "undefined local variable or method `copystr'".

If, instead, I use <% print copystr %>, it does recognize the variable, but prints it on stdout once while generating the pages and doesn't include it in the page output itself.

So, how do I get the contents of "copystr" included in all my pages?

Thanks,
-Markus