Giter Site home page Giter Site logo

Comments (5)

jmooring avatar jmooring commented on June 12, 2024 1

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.

chrillek avatar chrillek commented on June 12, 2024 1
  1. 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.

jmooring avatar jmooring commented on June 12, 2024 1

They are not properties. They are methods. For example:

  1. .RenderString is not a function. It is a method on the .Page object that renders markdown to HTML.
  2. .Title is a method on the .Page object that returns the front matter title field
  3. .Sections is a method on the .Site object that returns a collection of all the top level sections.

from hugodocs.

bep avatar bep commented on June 12, 2024

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.

chrillek avatar chrillek commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.