Comments (5)
I think the distinction between function and method is something that we need to preserve
I agree, and that is consistent with the glossary of terms.
What I am asking is, can we stop referring to things like .Page.IsHome
and .Page.Title
as variables, and call them methods instead?
from hugodocs.
- Things like "page variables" are not variable. They are immutable within a template.
Why not call them "properties"? That doesn't imply mutability (I think), but still permits to discern those from functions like RenderString
.
from hugodocs.
They are not properties. They are methods. For example:
.RenderString
is not a function. It is a method on the.Page
object that renders markdown to HTML..Title
is a method on the.Page
object that returns the front mattertitle
field.Sections
is a method on the.Site
object that returns a collection of all the top level sections.
from hugodocs.
So, it's still very much on my TODO list to get an auto generated reference section happening in Hugo. The recent config consolidation was a important part of this, and then I may have gotten distracted.
With that setup you would get this "Reference":
- Function namespaces
- Objects (Page, Site etc.)
- Configuration
- Go Types
While it's technically correct to say that Hugo's template functions are methods, they (mostly) behave like a function, and none of them have a "." context that the user needs to worry about, and I think the distinction between function and method is something that we need to preserve.
So with that, I would not spend high
amount of effort on things that would fall into the "Reference" category above.
from hugodocs.
Well, if they are methods… I doubt that kind of terminology helps clarify things, though. A getter like .Title
behaves in every way as a read-only property. Whereas .RenderString
acts on its parameter(s).
If you replace (most) "variable" by "method" the intro to Site variables
will read:
Site methods
Many, but not all, site-wide variables are defined in your site’s configuration. However, Hugo provides a number of built-in methods for convenient access to global values in your templates.
The following is a list of site-level (aka “global”) methods. Many of these methods are defined in your site’s configuration file, whereas others are built into Hugo’s core for convenient usage in your templates.
I do not think that that makes any sense, at all. The current wording is a lot less complex and easier to understand. Even if it might not be technically correct.
from hugodocs.
Related Issues (20)
- Segment configuration: example
- Document excluding content in Sitemap HOT 2
- Improve RSS feed HOT 1
- Fix TOC page
- Document time.Truncate and time.Round
- Document images.Color.Luminance and images.Color.ColorHex
- Document front matter params that are expected by embedded templates
- quick start guide: Remove usage of Ananke theme HOT 3
- Remove examples of LanguageCode fallback HOT 1
- symbolic link references in Documentation obsolete? HOT 2
- Describe build steps
- plainify doc doesn't say that it transforms chars into entities HOT 1
- Page.Summary doc doesn't say that the value is markdownify-ied HOT 2
- site.Taxonomies returns a page.WeightedPages, not a page.TaxonomyList HOT 2
- shortcodes doc page doesn't support dark mode HOT 2
- page.Sections example seems wrong
- Document Pager methods in methods section HOT 1
- gt doc only shows numbers
- Provide more detail related to HTTP caching and polling
- Unclear how i18n (lang.Translate) determines the target language HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hugodocs.