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

New $_hugo_config in shortcode do not work in some case in 0.55 #5831

Closed
divinerites opened this issue Apr 9, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@divinerites
Copy link

commented Apr 9, 2019

Tested on hugo latest v.0.55-DEV just before official release

  • Site with Uno theme : https://themes.gohugo.io/hugo-uno/
  • On v0.55-DEV everything compile fine and few WARNING/deprecated I removed. So it was green light for me.
  • I just tested it in server mode and i have a weird addition of <pre><code> plus what looks like encoding process.
  • None of my code or theme code has any test or whatever with <pre><code>

I guess it seems related to {{ .Content }} behaviour when called from a {{% shortcode as mentioned by Bep in #5827 (comment)

Adding {{ $_hugo_config := { "version": 1 } }} first line of shortcode didn't solved it.

ZIP file sent by mail (repo is private on our servers)

Good HTML with v0.54

<h1>Contrats / code Branche</h1>
#### PROBLEM IS FROM THERE
<section id="texteintro">
--
  |  
  |  
  | <p class="info" align="center">... [MODE SERVEUR HUGO] ...<p>
  | <p class="info">Fichier à traiter : csv/Portefeuille_02.csv</p>
  | <p class="info">N° de colonne à aggréger : 9</p>
  | <p class="info">Type de graphique par défaut : line</p>
  | </section>
  |  

bad HTML vwith v0.55-DEV

<h1>Contrats / code Branche</h1>
#### PROBLEM IS FROM THERE
<pre><code>    &lt;section id=&quot;texteintro&quot;&gt;
--
  |  
  |  
  | &lt;p class=&quot;info&quot; align=&quot;center&quot;&gt;... [MODE SERVEUR HUGO] ...&lt;p&gt;
  | &lt;p class=&quot;info&quot;&gt;Fichier à traiter : csv/Portefeuille_02.csv&lt;/p&gt;
  | &lt;p class=&quot;info&quot;&gt;N° de colonne à aggréger : 9&lt;/p&gt;
  | &lt;p class=&quot;info&quot;&gt;Type de graphique par défaut : line&lt;/p&gt;
  | &lt;/section&gt;

This is my content/stats/file.md

...
{{% csvdata-stats csvfile="csv/Portefeuille_02.csv" %}}

This is my layouts/shortcodes/csvdata-stats.html file

{{ $_hugo_config := `{ "version": 1 }` }}
...
{{ partial "csvdata-stats-unitaire.html" . }}
...

This is my layouts/partials/csvdata-stats-unitaire.html file

...
{{ if .Site.IsServer }}
        <section id="texteintro">
            <!-- Test pour les pages DRAFT -->
            {{ with $.Page.Draft }}
                <div id="draft-warning">DRAFT</div>
            {{ end }}
            <p class="info" align="center">... [MODE SERVEUR HUGO] ...<p>
            <p class="info">Fichier à traiter : {{  $.Scratch.Get "csvURL" }}</p>
            <p class="info">N° de colonne à aggréger : {{ $.Scratch.Get "csvNUMCOL_CATEG" }}</p>
            <p class="info">Type de graphique par défaut : {{ $.Scratch.Get "csv_graph_type" }}</p>
        </section>
{{ end }}
...

This is the part where this code is generated in theme/uno/layouts/_default/single.html

    {{ partial "head.html" . }}
    <body>
        {{ partial "sidebar.html" . }}
        <div class="content-wrapper">
            <div class="content-wrapper__inner">
                <div class="post">
                    <h1>{{ .Title }}</h1>
#### PROBLEM IS FROM THERE
                    {{ .Content }}
                </div>
            </div>
        </div>
    </body>
    {{ partial "script.html" .}}
</html>

@divinerites divinerites changed the title New $_hugo_config in shortcode do not work when partial are involved in 0.55 New $_hugo_config in shortcode do not work in some case in 0.55 Apr 9, 2019

@bep bep added this to the v0.55.1 milestone Apr 9, 2019

@divinerites divinerites closed this Apr 9, 2019

@divinerites divinerites reopened this Apr 9, 2019

@divinerites

This comment has been minimized.

Copy link
Author

commented Apr 10, 2019

Tried different combinations of {{<>}} and markdonify and $_hugo_config without success.

May be impacted by the cascading partials involved ??

@divinerites

This comment has been minimized.

Copy link
Author

commented Apr 12, 2019

Sorry for not doing this before : This is a repo showing the problem in 0.55 and working in 0.54.

https://github.com/divinerites/mytest

@bep bep modified the milestones: v0.55.1, v0.56 Apr 12, 2019

@divinerites

This comment has been minimized.

Copy link
Author

commented Apr 17, 2019

I minimized the evidence repo and narrowed the problem.

I can reproduce this behaviour with this test-bug.html shortcode. It seems related to spaces before HTML code, where the $_hugo_config is without effect called by {{% test-bug %}}

{{ $_hugo_config := `{ "version": 1 }` }}

<div>
    some text with HTML BUT WITHOUT SPACE BEFORE<p>
</div>

    <div>
        some text with HTML AND WITH SPACES BEFORE<p>
    </div>

    {{ partial "partial_1.html" . }}


<div>
    some text with HTML BUT WITHOUT SPACE BEFORE<p>
</div>

Here is the result

Capture d’écran 2019-04-17 à 14 26 27

@bep bep modified the milestones: v0.56, v0.55.4 Apr 23, 2019

@bep bep added the Bug label Apr 24, 2019

bep added a commit to bep/hugo that referenced this issue Apr 24, 2019

@bep bep closed this in #5899 Apr 24, 2019

bep added a commit that referenced this issue Apr 24, 2019

@divinerites

This comment has been minimized.

Copy link
Author

commented Apr 24, 2019

Just tested 0.56-DEV with your commit. Works like a charm now. Many many thanks !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.