Skip to content

Instantly share code, notes, and snippets.

@tka
Last active December 11, 2015 02:59
Show Gist options
  • Save tka/4534770 to your computer and use it in GitHub Desktop.
Save tka/4534770 to your computer and use it in GitHub Desktop.
<%
@page_body=yield
special_comment_regexp = /<!--ruby:(.*)-->/m
if @page_body.match(special_comment_regexp)
eval($1)
@page_body.gsub!(special_comment_regexp, '')
elsif @page_body.match(/<h1.*?>(.*)<\/h1>/)
@page_title = $1
else
filename = Serve::Router.resolve(Compass.configuration.project_path, request.env["PATH_INFO"])
@page_title = File.basename(filename).split(/\./).first.gsub(/[_-]/, ' ')
end
%>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= @page_title + " - " if @page_title %>My Awesome Blog Name</title>
</head>
<body>
<%= @page_body %>
</body>
</html>

Title Here

  • A
    • D
  • B
    • E
  • C
    • F

I am not page title

  • A
    • D
  • B
    • E
  • C
    • F

I am <h2>, not page title

  • A
    • D
  • B
    • E
  • C
    • F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment