Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation about order of interpretation #5834

Merged
merged 4 commits into from Feb 11, 2017
Merged

Add documentation about order of interpretation #5834

merged 4 commits into from Feb 11, 2017

Conversation

tomjoht
Copy link
Contributor

@tomjoht tomjoht commented Jan 30, 2017

This tutorial defines Jekyll's "order of interpretation," as @swizca called it in #5808. This tutorial makes it clear how Jekyll processes files as it renders the static HTML output.

This order-of-interpretation info is important for troubleshooting and generally understanding Jekyll. It's important to know how Jekyll generates out the files, what rules it uses, what order it processes things, and so forth.

(Note: Please process #5698 before this request, because #5698 includes the tutorial collection/navigation that this tutorial fits into. I also need to update this commit to add a link in the Tutorials nav to this topic, but I'm waiting for #5698 to be merged so that menu becomes available.)

@jekyll/core

This tutorial defines Jekyll's "order of interpretation," as @swizca called it in [#5808](#5698). This tutorial makes it clear how Jekyll processes files as it renders the static HTML output.

This order-of-interpretation info is important for troubleshooting and generally understanding Jekyll. It's important to know how Jekyll generates out the files, what rules it uses, what order it processes things, and so forth.

(Note: Please process 5698 before this request, because 5698 includes the tutorial collection/navigation that this tutorial fits into. I also need to update this commit to add a link in the Tutorials nav to this topic, but I'm waiting for 5698 to be merged so that menu becomes available.)

@jekyll/documentation
@DirtyF
@ashmaroli
Copy link
Member

ashmaroli commented Jan 30, 2017

Just did a rough read-through.. found a few occurrences of {{variable}} instead of {{ variable }}.

[Random comment]: You have cautioned the user to never mix javascript and liquid due the difference in their individual processing.. and that is true in the context of this tutorial, but not something that should never be done.
Just for knowledge purposes,
The jekyll-assets plugin processes all .liquid files with Jekyll context.
If you give it a style.css.liquid containing liquid variables, it'll be processed into a valid style.css, a script.js.liquid into a script.js. But yes, core Jekyll doesn't.

```
{% raw %}{{site.data.mydata.somevalue}}{% endraw %}
```
Nothing renders because first the site variables populate, and then Liquid renders. When the site variables populate, the value for `{% raw %}{{site.data.mydata.somevalue}}{% endraw %}` is simply `{% raw %}{{myvar}}{% endraw %}`, which registers as a string and gets printed as a string. You can't use Liquid in data files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does “nothing render,” or does it render as the string “{{myvar}}?”

{% raw %}{% include mycontent.md %}{% endraw %}
```

The Markdown is not processed because first the Liquid (`include` tag) gets processed, inserting `mycontent.md` into the HTML file. *Then* the Markdown would get processed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

}{% endraw %}
```

The Liquid renders long before the page gets converted to HTML. So when JavaScript executes in the browser, the Liquid is no longer present.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. I don't see any Liquid in the given JavaScript. There is a way to make it work:

if {{ page.type | jsonify }} === "home"
    …


The Liquid renders long before the page gets converted to HTML. So when JavaScript executes in the browser, the Liquid is no longer present.

You can never mix Liquid with JavaScript because Liquid processes when the site builds. In contrast, JavaScript processes in the browser when a user interacts with your site.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what you're trying to say, but perhaps some different language could be used. Mixing Liquid and JavaScript might be Expert Mode, but it's not impossible.


```liquid
{% raw %}if page.type == "home" {
$("intro").addClass("bright");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave jQuery out of this; confusing enough as is.

@swizca
Copy link

swizca commented Jan 30, 2017 via email

@DirtyF
Copy link
Member

DirtyF commented Jan 30, 2017

{{variable}} instead of {{ variable }}
Why is this a concern? (Link?)

This is the convention used on the whole website, it's a bit more readable.
http://ben.balter.com/jekyll-style-guide/liquid-syntax/#general-syntax

@swizca
Copy link

swizca commented Jan 30, 2017

This is the convention used on the whole website, it's a bit more readable.
http://ben.balter.com/jekyll-style-guide/liquid-syntax/#general-syntax

Thanks! [Indentation, style, readability, given the differing processors involved, is something I still haven't wrapped my head around / chased down to a coherent whole. (Yaml being unhappy with tabs, multiple processors reacting to lack/presence of extra spacing, code blocks, and so on.)]

@ashmaroli
Copy link
Member

This is without the presence of Front Matter?

I haven't used the plugin myself but the plugin's README does caution the user from setting features.liquid to true

@tomjoht
Copy link
Contributor Author

tomjoht commented Jan 30, 2017

I made the updates that you all suggested. Thanks! Submitting for re-review.

I moved the section about liquid and yaml to the end and shortened it. i also clarified that isn't an order-of-interpretation issue why liquid doesn't render in yaml. I also fixed the type with HMTL.
@tomjoht
Copy link
Contributor Author

tomjoht commented Feb 4, 2017

I fixed the issues noted in the reviews. Resubmitting for approval.

Hey, just curious, but things seem extra quiet in this repo lately. Is everyone taking a break after the release, or battling with jekyll talk issues?

Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small typos


1. **Site variables**. Jekyll looks across your files and populates [site variables]({% link _docs/variables.md %}), such as `site`, `page`, `post`, and collection objects. (From these objects, Jekyll determines the values for permalinks, tags, categories, and other details.)

2. **Liquid**. Jekyll processes any Liquid formatting in pages that contain [front matter]({% link _docs/frontmatter.md %}). All Liquid tags, such as `include`, `highlight`, or `assign` tags, are rendered. (Anything in Jekyll with `{% raw %}{{ }}{% endraw %}` curly braces or `{% raw %}{% %}{% endraw %}` is usually a Liquid filter or tag.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ Liquid filter/Liquid variable

Copy link
Member

@ashmaroli ashmaroli Feb 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of saying

(Anything in Jekyll with {% raw %}{{ }}{% endraw %} curly braces or {% raw %}{% %}{% endraw %} is
usually a Liquid filter or tag.)

and generalising, I feel its better to inform what's what.. i.e. :


Identify Liquid by the presence of curly brackets / braces:

  • Liguid Tags: They start with a {% and end with a %}. e.g. {% raw %}, {% highlight %}, {% css -- %}, {% seo %}. Tags can define blocks or can be inline. Block-defining tags will additionally come with a corresponding end-tag
    i.e {% endraw %}, {% endhighlight %}
  • Liquid Variables: They start and end with double-braces. e.g. {{ site.myvariable }} , {{ content }}
  • Liquid Filters: They start with a pipe character (|) and can only be used within Liquid Variables after the variable string. e.g relative_url filter in {{ "css/main.css" | relative_url }}

Learn more about Liquid by referring the official documentation [LINK]


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. i like this extra specificity.


For the most part, you don't have to think about the order of interpretation when building your Jekyll site. These details only become important to know when something isn't rendering.

The following scenarios highlight potential problems you might encounter. These problems stem from misunderstanding the order of interpretation and can be easily fixed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/stem/step?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DirtyF
These problems come from…?
These problems are rooted in…?

Mostly I added more detail in the Liquid section.
@tomjoht
Copy link
Contributor Author

tomjoht commented Feb 6, 2017

I made updates based on the latest review. Resubmitting for consideration.

On another note, any update about when we can push out this new tutorials section? Are you waiting on me for anything related to that?

@parkr
Copy link
Member

parkr commented Feb 11, 2017

Thank you!

@jekyllbot: merge +site

@jekyllbot jekyllbot merged commit 2c1991f into jekyll:master Feb 11, 2017
jekyllbot added a commit that referenced this pull request Feb 11, 2017
@parkr
Copy link
Member

parkr commented Feb 11, 2017

any update about when we can push out this new tutorials section? Are you waiting on me for anything related to that?

We can push it out anytime! We need: an index.html file to greet the users and it needs to be added to the collections Hash in docs/_config.yml.

@tomjoht
Copy link
Contributor Author

tomjoht commented Feb 11, 2017

PR 5698 needs to be pushed before this one. PR5698 contains all the edits around enabling the tutorials collection and navigation. After 5698 goes live, then I'll add another link in the nav for this topic. I have another tutorial I'm about to submit as well, so we'll soon have 3 tutorials in that new Tutorials nav.

@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants