suppose we need to create a copyright statement which shows current year dynamically.
in the language text file (en.yml), we expect a variable current_year:
This file contains 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
en: | |
layout: | |
copyright_statement: "© 2010 - %{current_year} RU05. All rights reserved." |
in the layout view, we provide this current_year as hash:
This file contains 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
<html> | |
... | |
<body> | |
... | |
<div id="footer"> | |
<%= I18n.t("layout.copyright_statement", :current_year => Date.today.year) %> | |
</div> | |
... | |
</body> | |
</html> |
No comments:
Post a Comment