I am following this link to figure out how to create an archives page. I am using the hugo-xmin theme with slight modifications.
As far as I understand, range goes through the pages and should print them out. But, I am getting an additional 0001 also. I don't understand why. I'm still a beginner to Hugo and Go.
My output (circled portion in red not what I want)
My archives.html
{{ partial "header.html" . }}
<div class="article-meta">
<h1><span class="title">{{ .Title | markdownify }}</span></h1>
{{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
{{ if (gt .Params.date 0) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end }}
</div>
<main class="content" role="main">
<div class="inner">
{{ range (.Site.RegularPages.GroupByDate "2006") }}
<h3>{{ .Key }}</h3>
<ul>
{{ range (where .Pages "Type" "post") }}
<li>
<span class="date">{{ .Date.Format "2006/01/02" }}</span>
{{ .Title }}
</li>
{{ end }}
</ul>
{{ end }}
</div>
</main>
{{ partial "footer.html" . }}
My archives.md
---
title: "Archives"
layout: "archives"
draft: false
---
This is archives
My directory structure
.
├── archetypes
│ └── default.md
├── config.toml
├── content
│ ├── about.md
│ ├── archives.md
│ ├── _index.md
│ ├── post
│ │ ├── first_post.md
│ │ ├── sample_code.md
│ │ └── test_math.md
│ └── reading.md
├── data
├── layouts
├── static
└── themes
└── mytheme
├── archetypes
│ └── default.md
├── layouts
│ ├── 404.html
│ ├── archives.html
│ ├── _default
│ │ ├── archives.html
│ │ ├── list.html
│ │ ├── single.html
│ │ └── terms.html
│ ├── index.html
│ └── partials
│ ├── foot_custom.html
│ ├── footer.html
│ ├── head_custom.html
│ └── header.html
├── LICENSE.md
├── static
│ ├── css
│ │ ├── fonts.css
│ │ └── style.css
│ └── js
└── theme.toml
15 directories, 25 files
I changed my archives.html to the following, with some help from hugo-lithium. It works for my use case now. But I still don't understand why the 0001 came up in the first place. So I will not be marking my answer as correct for now.
{{ partial "header.html" . }}
<div class="article-meta">
<h1><span class="title">{{ .Title | markdownify }}</span></h1>
{{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
{{ if (gt .Params.date 0) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end }}
</div>
{{ range (where .Site.RegularPages "Section" "!=" "").GroupByDate "2006" }}
<h2>{{ .Key }}</h2>
<ul>
{{ range .Pages }}
<li>
<span class="date">{{ .Date.Format "2006/02/02" }}</span>
{{ .Title }}
</li>
{{ end }}
</ul>
{{ end }}
{{ partial "footer.html" . }}
Related
I'm trying to create a templated file with jinja2 and ansible
currently i have a dict with multiple entries e.g:
internal_sites:
- {name: "site1" ,url: "site1.example.com" }
- {name: "site2" ,url: "site2.example.com" }
- {name: "site3" ,url: "site3.example.com" }
- {name: "site4" ,url: "site4.example.com" }
I have a a directory that has multiple files eached also named after the value in 'name'
├── templates
│ ├── base.cfg.j2
│ └── services
│ ├── internal
│ │ ├── site1.txt
│ │ ├── site2.txt
│ │ ├── site3.txt
│ │ ├── site4.txt
Within base.cfg.j2 im trying to loop over each item in internal_sites which generates the appropriate config i require and at the same time im trying to include the content of the text files.
the instructions i have are as follows:
{% for site in internal_sites %}
acl {{ site.name }} hdr(host) -i {{ site.url }}
use_backend {{ site.name }} if {{ site.name }}
backend {{ site.name}}
{% include "templates/services/internal/"{{lookup('vars', site.name)}} %}
{% endfor %}
however whenever i run my ansible i get the following error;
FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: expected token 'end of statement block', got '{'. String: \n{% for site in internal_sites %}\n acl {{ site.name }} hdr(host) -i {{ site.url }}\n use_backend {{ site.name }} if {{ site.name }}\n\n backend {{ site.name}}\n {% include \"templates/services/internal/\"{{lookup('vars', site.name)}} %}\n\n{% endfor %}\n"}
i have also tried with the following
{% for site in internal_sites %}
{% set fileloc = 'templates/services/internal/' + site.name %}
acl {{ site.name }} hdr(host) -i {{ site.url }}
use_backend {{ site.name }} if {{ site.name }}
backend {{ site.name}}
{% include {{fileloc}} %}
{% endfor %}
I'm aware this is likely wrong but could anyone shed some guidance on the most appropriate way to do this?
expected output
acl site1 hdr(host) -i site1.example.com
use_backend site1 if site1
backend site1
contents of site1.txt
are included
here
I'm having n issue with loading html files with go gin framework
when i loaded the entire templates folder from the main function its not reading the subdirectories and only read files .
package app
import (
"github.com/gin-gonic/gin"
)
var (
router = gin.Default()
)
func StartApp() {
router.LoadHTMLGlob("templates/*/*.html")
routersMap()
router.Run(":8080")
}
based on the project structure it supposed to show the Loaded HTML Templates as
[GIN-debug] Loaded HTML Templates (2):
- layouts/default.html
- layouts/index.html
- pages/index.html
but actually the output showing this result
[GIN-debug] Loaded HTML Templates (3):
- default.html
- index.html
-
it doesn't even showing the second index.html file
Project Structure
I am also working on learning go and using gin.
I came across this issue also and ran into a few minor issues that i resolved.
I will leave this here in case it may someone else.
Folder layout:
.
├── controllers
│ ├── controller.go
│ └── gui.go
├── html
│ └── templates
│ ├── homepage
│ │ └── index.html
│ ├── layouts
│ │ ├── footer.html
│ │ ├── header.html
│ │ └── menu.html
│ └── views
│ └── library.html
├── models
│ ├── bookstruct.go
│ └── dbconnection.go
├── server.go
└── test
└── server_test.go
The part that is probably needed are these files:
server.go
gui.go
library.html
gui.go
package controllers
import (
"net/http"
"github.com/gin-gonic/gin"
)
...
// BooksView display book library
func BooksView(c *gin.Context) {
c.HTML(
http.StatusOK,
"views/library.html",
gin.H{"title": "Books"},
)
}
library.html
{{ define "views/library.html" }}
<!--Embed the header.html template at this location-->
{{ template "layouts/header.html" .}}
<h1>Hello Books!</h1>
<div>Est nisi debitis recusandae necessitatibus voluptate ut. Laudantium eligendi nostrum quisquam voluptates harum
exercitationem nam harum. Voluptatem sit assumenda sit alias dolores. Modi autem et temporibus impedit qui numquam.
Esse ut recusandae quos deserunt nihil repellendus. Sint et voluptatem quia quia dolor aut.</div>
<div>Est nisi debitis recusandae necessitatibus voluptate ut. Laudantium eligendi nostrum quisquam voluptates harum
exercitationem nam harum. Voluptatem sit assumenda sit alias dolores. Modi autem et temporibus impedit qui numquam.
Esse ut recusandae quos deserunt nihil repellendus. Sint et voluptatem quia quia dolor aut.</div>
<!--Embed the footer.html template at this location-->
{{ template "layouts/footer.html" .}}
{{ end }}
server.go
import (
c "go_first_api/sub_packages/gormrestapi/controllers"
m "go_first_api/sub_packages/gormrestapi/models"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog"
)
// RunServer will run and create a server using gin
func RunServer() {
...
r := gin.Default()
r.LoadHTMLGlob("sub_packages/gormrestapi/html/templates/**/*")
r.GET("/library", c.BooksView)
...
r.Run(":8088")
}
NOTE: main.go is above this sub-dir in the folder path.
See gin#html-rendering,
Using templates with same name in different directories templates/**/*.
I have a laravel app structured to has separate resources for both customers and admins. Inside the app, on the admin side, I have checkboxes for controlling the visibility of some components on a front (customer) page. Now, in addition to the visibility, I have some extra params to display. So, in order to verify changes immediately, I would like to preview (not include) front.blade.php inside admin.blade.php?
My only idea right now is to use <iframe>, but I am hoping to find something that is called "laravel way".
My project's structure :
resources
|-- admin
| |-- views
| |-- layouts
| |-- website
| `-- front.blade.php
|
|-- front
| |-- views
| |-- layouts
| |-- website
| `-- admin.blade.php
admin.blade.php
#section('section','Website')
#section('title','Home')
#extends('layouts.main')
#section('style')
<link href="{{ admin_asset('assets/admin/css/main.css') }}" rel="stylesheet" type="text/css" />
#endsection
#section('content')
<div class="contentbar">
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">Header</div>
<div class="card-body">
#include('website.front') <--- include doesn't work. It just brakes the whole view
</div>
<div class="card-footer">Footer</div>
</div>
</div>
</div>
</div>
#endsection
#section('script')
<script src="{{ admin_asset('assets/admin/js/main.min.js') }}"></script>
#endsection
config/view.php
'paths' => [
resource_path('front/views'),
resource_path('admin/views'),
],
I don't know why you change the default resource\views path and include all your organized view folder inside to be like :
resources
|-- views
| |-- admin
| |-- layouts
| |-- website
| `-- front.blade.php
|
| |-- front
| |-- layouts
| |-- website
| `-- admin.blade.php
but if you want to keep your structure, so you have to make these changes to make it works:
config/view.php
'paths' => [
resource_path('views'),
],
and in your blade you can do something like:
#include(resource_path('admin\views\layouts\website\front.blade.php'))
I have a YAML array in a file called navigation.yml as follows:
docs:
- title: Home
url: index.md
id: index
- title: Support
url: support.html
id: support
- title: About
url: about.md
id: about
I am creating a navigation bar as follows:
<section id="navigation" class="clearfix">
{% for item in site.data.navigation.docs %}
<span>{{ item.title }}</span>
{% endfor %}
</section>
What should I put in place of index.md to get the item.url that I want from the YAML file.
I am totally new to GitHub Pages, YAML, and Jekyll.
At the moment, the link tag doesn't seem to support variables.
There's a pull request trying to change this, but it has not been merged into the main Jekyll repo yet.
So if you want to do this now, you need to use some tricks.
The solution suggested by flyx in his comment (replace {% link index.md %} by {{ item.url }}) basically works, but shows the original filename written in the data file.
⇒ If index.md is automatically renamed to index.html while rendering the site, your link won't work anymore.
(or if support.html becomes support/index.html)
That's probably why you wanted to use the link tag instead.
Without using the link tag, you need to loop your data file, loop through all pages to find the respective page, and show that page's actual URL in your link:
<section id="navigation" class="clearfix">
{% for item in site.data.navigation.docs %}
{% for page in site.pages %}
{% if page.path == item.url %}
<span>{{ item.title }}</span>
{% endif %}
{% endfor %}
{% endfor %}
</section>
This even takes stuff like explicitly set permalinks (permalink: /whatever/ in the page's front matter) into account.
Using sample-Groceries-angular
I'm trying to focus password instead of email by clicking a button
┌──────────────────┬─────────────────┬────────────────┬───────────────┐
│ Component │ Current version │ Latest version │ Information │
│ nativescript │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-core-modules │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-android │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-ios │ │ 2.3.0 │ Not installed │
└──────────────────┴─────────────────┴────────────────┴───────────────┘
xml:
<TextField #email hint="Email Address" keyboardType="email" [(ngModel)]="user.email"
autocorrect="false" autocapitalizationType="none"></TextField>
<TextField #password hint="Password" secure="true" [(ngModel)]="user.password"></TextField>
<Button text="Focus Password" (tap)="focusDat()"></Button>
typescript:
#ViewChild("password") password: ElementRef;
focusDat() {
let password = <TextField>this.name.nativeElement;
console.log(password.focus());
}
output:
JS: false
Thanks to Nikolay Tsonev I just focused the wrong field
was:
let password = <TextField>this.name.nativeElement;
should be:
let password = <TextField>this.password.nativeElement;
it's working fine, just made a silly mistake...
you should refer this I tried to create OTP mech.
<TextField col="0" maxlength="1" (textChange)="o1()" verticalAlignment="center" style.placeholderColor="gray" [(ngModel)]="one" required #1ng="ngModel" returnKeyType="next" keyboardType="number"></TextField>
<TextField col="1" maxlength="1" #b (textChange)="o2()" verticalAlignment="center" style.placeholderColor="gray" [(ngModel)]="two" required #2ng="ngModel" returnKeyType="next" keyboardType="number"></TextField>
<TextField col="2" maxlength="1" #c (textChange)="o3()"verticalAlignment="center" style.placeholderColor="gray" [(ngModel)]="three" required #3ng="ngModel" returnKeyType="next" keyboardType="number"></TextField>
<TextField col="3" maxlength="1" #d verticalAlignment="center" style.placeholderColor="gray" [(ngModel)]="four" required #4ng="ngModel" returnKeyType="done" keyboardType="number"></TextField>
.ts
one=''
two=''
three=''
four=''
#ViewChild("b", { static: false }) b: ElementRef;
#ViewChild("c", { static: false }) c: ElementRef;
#ViewChild("d", { static: false }) d: ElementRef;
o1(){
this.b.nativeElement.focus()
}
o2(){
this.c.nativeElement.focus()
}
o3(){
this.d.nativeElement.focus()
}