Commit ead12ff1 authored by key-amb's avatar key-amb
Browse files

Refactor using {{ with X }} instead of {{ if X }} in templates

parent 67c71039
......@@ -7,7 +7,7 @@
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>{{ .Site.Title }}</h1>
<p>{{ if .Site.Params.description }}{{ .Site.Params.description }}{{ else }}You can customize this text by params "description" in your <code>config.toml</code>.{{ end }}</p>
<p>{{ with .Site.Params.description }}{{ . }}{{ else }}You can customize this text by params "description" in your <code>config.toml</code>.{{ end }}</p>
</div>
</div>
......@@ -41,11 +41,12 @@
</div>
</div>
{{ if .Site.Params.withSitePosts }}
{{ $title := .Site.Title }}
{{ with .Site.Params.withSitePosts }}
<hr />
<div class="row doc-main text-center">
<a href="{{ $baseUrl }}/post">See posts for {{ .Site.Title }}</a>
<a href="{{ $baseUrl }}/post">See posts for {{ $title }}</a>
</div>
{{ end }}
......
......@@ -9,7 +9,7 @@
<link rel="icon" href="{{ $baseUrl }}/favicon.ico">
<title>{{ .Title }}{{ if eq $isHomePage false }} - {{ .Site.Title }}{{ end }}</title>
<!--<link href="http://fonts.googleapis.com/css?family=PT+Sans:400,700" rel="stylesheet" type="text/css">-->
<link rel="stylesheet" href="{{ $baseUrl }}/css/highlight/{{ if .Site.Params.highlightStyle }}{{ .Site.Params.highlightStyle }}{{ else }}default{{ end }}.css">
<link rel="stylesheet" href="{{ $baseUrl }}/css/highlight/{{ with .Site.Params.highlightStyle }}{{ . }}{{ else }}default{{ end }}.css">
<link rel="stylesheet" href="{{ $baseUrl }}/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ $baseUrl }}/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="{{ $baseUrl }}/css/theme.css">
......@@ -33,14 +33,14 @@
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li {{ if eq $isHomePage true }}class="active"{{ end }}><a href="{{ $baseUrl }}/">Home</a></li>
{{ if .Site.Params.mainMenu }}
{{ $url := .Permalink }}
{{ range $menu := .Site.Params.mainMenu }}
{{ $url := .Permalink }}
{{ with .Site.Params.mainMenu }}
{{ range $menu := . }}
{{ $itemUrl := printf "%s/%s/" $baseUrl $menu.link }}
<li {{ if eq $url $itemUrl }}class="active"{{ end }}><a href="{{ $baseUrl }}/{{ $menu.link }}">{{ $menu.name }}</a></li>
{{ end }}
{{ end }}
{{ if .Site.Params.noCategoryLink }}{{ else }}
{{ if not .Site.Params.noCategoryLink }}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Categories<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
......@@ -51,10 +51,10 @@
</li>
{{ end }}
</ul>
{{ if .Site.Params.searchDomain }}
{{ with .Site.Params.searchDomain }}
<form class="navbar-form navbar-left" role="search" action="https://www.google.co.jp/search" method="get">
<div class="input-group doc-search-form">
<input type="hidden" name="as_sitesearch" value="{{ .Site.Params.searchDomain }}">
<input type="hidden" name="as_sitesearch" value="{{ . }}">
<input type="text" name="as_q" class="search-query doc-search-input-text" placeholder="Search Site">
<span class="input-group-addon input-group-btn doc-search-input-btn">
<button class="btn" type="submit"><span class="glyphicon glyphicon-search"></span></button>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment