From c84da35eb80a638bb63ab09419dd652f85d89267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tayfun=20O=CC=88zis=CC=A7=20ERI=CC=87KAN?= Date: Sat, 10 Aug 2013 01:50:29 +0300 Subject: [PATCH] #27 Custom view helpers was created --- helpers/view_helpers.rb | 12 ++++++++++++ source/layouts/layout.haml | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 helpers/view_helpers.rb diff --git a/helpers/view_helpers.rb b/helpers/view_helpers.rb new file mode 100644 index 0000000..e46a9a4 --- /dev/null +++ b/helpers/view_helpers.rb @@ -0,0 +1,12 @@ +module ViewHelpers + def page(title, id) + @page_id = id + content_for :title do + title + end + end + + def launcher_active(page) + @page_id == page ? {class:'active'} : {} + end +end \ No newline at end of file diff --git a/source/layouts/layout.haml b/source/layouts/layout.haml index 697030c..28dc5c9 100755 --- a/source/layouts/layout.haml +++ b/source/layouts/layout.haml @@ -4,7 +4,7 @@ /[if lt IE 10] %html{lang: 'en', class: 'no-js'} %head - %title= @title || 'Hierapolis' + %title= yield_content :title %meta(http-equiv="content-type" content="text/html" charset="utf-8") %meta(http-equiv="x-ua-compatible" content="ie=edge,chrome=1") %meta(name="description" content="") @@ -25,7 +25,7 @@ '//netdna.bootstrapcdn.com/font-awesome/3.2.0/css/font-awesome.min.css' = yield_content :head - %body{class: @body_class || 'page'} + %body.main{class: @page || 'page'} / Navbar = partial 'partials/navbar'