Created
April 19, 2011 17:26
-
-
Save vividsnow/928924 to your computer and use it in GitHub Desktop.
Draft example of Template::Semantic usage
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
sub wrap { | |
my ($self, $data) = @_; | |
return $self->engine->process($self->path.'/layout.html', { | |
'//head' => { | |
'title' => $data->{title}, | |
'./script[last()-1]' => @{$data->{js}}?[map { './@src' => '/js/'.$_.'.js' }, @{$data->{js}}]:undef, | |
'./link[last()]' => @{$data->{js}}?[map { './@href' => '/css/'.$_.'.css'}, @{$data->{css}}]:undef, | |
'./script[last()]' => $data->{jscode}?sub { $_ =~ s/\/\*code\*\//$data->{jscode}/; \$_ }:undef, | |
}, | |
'//body' => { | |
header => { | |
h1 => $data->{title}, | |
'div.notice' => $data->{notice} || $data->{error}, | |
'div.auth' => { | |
'span.user a' => exists($data->{me})?{ | |
'.' => $data->{me}->name, | |
'@href' => '/profile/'.$data->{me}->name | |
}:{ | |
'.' => 'Anonymous' | |
} | |
} | |
}, | |
'div#main' => $data->{content} | |
} | |
}); | |
} |
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 class="no-js"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<title>Page Title</title> | |
<meta name="description" content="Page Description" /> | |
<meta name="author" content="" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<link rel="shortcut icon" href="/images/favicon.ico" /> | |
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png" /> | |
<link rel="stylesheet" href="/css/style.css?v=2" /> | |
<link rel="stylesheet" href="/css/css3buttons.css" media="screen" /> | |
<link rel="stylesheet" media="handheld" href="/css/handheld.css?v=2" /> | |
<script src="//ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script> | |
<script src="/js/libs/modernizr-1.7.min.js"></script> | |
<link href="" rel="stylesheet" /> | |
<script src=""></script> | |
<script type="application/x-javascript"> | |
//<![CDATA[ | |
Event.observe(document, 'dom:loaded', function() { | |
/*code*/ | |
}); | |
//]]> | |
</script> | |
</head> | |
<body> | |
<div class="layout"> | |
<header class="b-head"> | |
<h1>Page Title</h1> | |
<div class="auth"> | |
<span class="user"> | |
Hi, <a href="#">User</a> | |
</span> | |
</div> | |
<div class="notice"></div> | |
</header> | |
<div id="main" role="main" class="b-content"></div> | |
<footer class="b-footer"></footer> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment