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

Rendering fails with no errors #12

Open
obahareth opened this issue Sep 4, 2017 · 2 comments
Open

Rendering fails with no errors #12

obahareth opened this issue Sep 4, 2017 · 2 comments

Comments

@obahareth
Copy link
Contributor

obahareth commented Sep 4, 2017

I'm building a Base16 builder in Elixir and I've come across a case where rendering is failing with no errors. Here's my test case:

defmodule TestMustache do 
  def test_mustache() do
    data = %{
      "base04-rgb-b" => 109.0,
      "base07-rgb-g" => 23.0,
      "base00-dec-b" => 0.9568627450980393,
      "scheme-name" => "Atelier Cave Light",
      "base0C-rgb-r" => 57.0,
      "base00-dec-r" => 0.9372549019607843,
      "base0C-dec-g" => 0.5450980392156862,
      "base0B-rgb-r" => 42.0,
      "base04-rgb-r" => 101.0,
      "base04-hex-r" => "65",
      "base0B-hex" => "2a9292",
      "base0E-hex" => "955ae7",
      "base0E-dec-b" => 0.9058823529411765,
      "base0F-dec-b" => 0.7490196078431373,
      "base0D-hex-r" => "57",
      "base07-hex-b" => "1c",
      "base08-dec-g" => 0.27450980392156865,
      "base08-hex-r" => "be",
      "base05-rgb-b" => 96.0,
      "base0E-dec-g" => 0.35294117647058826,
      "base01-dec-r" => 0.8862745098039215,
      "base0F-rgb-r" => 191.0,
      "base09-hex-g" => "57",
      "base09-rgb-r" => 170.0,
      "base01-hex-r" => "e2",
      "base01-hex" => "e2dfe7",
      "base06-dec-r" => 0.14901960784313725,
      "base05-hex-r" => "58",
      "base05-dec-g" => 0.3215686274509804,
      "base01-rgb-b" => 231.0,
      "base0A-rgb-r" => 160.0,
      "base00-hex-g" => "ec",
      "base0C-hex-r" => "39",
      "base02-dec-r" => 0.5450980392156862,
      "base0C-dec-b" => 0.7764705882352941,
      "base07-dec-r" => 0.09803921568627451,
      "base04-dec-g" => 0.37254901960784315,
      "base0B-hex-g" => "92",
      "base00-rgb-g" => 236.0,
      "base07-hex-r" => "19",
      "base0D-rgb-g" => 109.0,
      "base07-hex-g" => "17",
      "base0C-hex-b" => "c6",
      "base09-rgb-b" => 60.0,
      "scheme-author" => "Bram de Haan (http://atelierbramdehaan.nl)",
      "base04-hex-b" => "6d",
      "base02-rgb-r" => 139.0,
      "base00-hex" => "efecf4",
      "base03-hex-r" => "7e",
      "base08-hex-b" => "78",
      "base03-hex-g" => "78",
      "base0A-rgb-b" => 59.0,
      "base06-rgb-b" => 42.0,
      "base0C-rgb-g" => 139.0,
      "base0B-dec-r" => 0.16470588235294117,
      "base04-rgb-g" => 95.0,
      "base0E-rgb-r" => 149.0,
      "base06-hex-b" => "2a",
      "base0D-rgb-r" => 87.0,
      "base0B-rgb-g" => 146.0,
      "base09-dec-b" => 0.23529411764705882,
      "base00-hex-r" => "ef",
      "base02-dec-g" => 0.5294117647058824,
      "base08-dec-r" => 0.7450980392156863,
      "base0A-hex-r" => "a0",
      "base09-hex" => "aa573c",
      "base06-dec-b" => 0.16470588235294117,
      "base07-hex" => "19171c",
      "base05-dec-r" => 0.34509803921568627,
      "base04-hex" => "655f6d",
      "base01-rgb-g" => 223.0,
      "base02-dec-b" => 0.5725490196078431,
      "base0A-hex" => "a06e3b",
      "base0F-rgb-b" => 191.0,
      "base07-dec-b" => 0.10980392156862745,
      "base06-rgb-g" => 35.0,
      "base08-rgb-g" => 70.0,
      "base07-rgb-b" => 28.0,
      "base0F-dec-g" => 0.25098039215686274,
      "base05-dec-b" => 0.3764705882352941,
      "base0C-dec-r" => 0.2235294117647059,
      "base02-hex" => "8b8792",
      "base0A-dec-b" => 0.23137254901960785,
      "base0E-rgb-g" => 90.0,
      "base02-hex-b" => "92",
      "base06-hex-g" => "23",
      "base0F-rgb-g" => 64.0,
      "base06-hex" => "26232a",
      "base0C-rgb-b" => 198.0,
      "base04-dec-b" => 0.42745098039215684,
      "base0A-rgb-g" => 110.0,
      "base05-hex-g" => "52",
      "base01-dec-b" => 0.9058823529411765,
      "base0B-rgb-b" => 146.0,
      "base07-dec-g" => 0.09019607843137255,
      "base01-hex-b" => "e7",
      "base00-hex-b" => "f4",
      "base03-hex" => "7e7887",
      "base0E-hex-b" => "e7",
      "base05-hex-b" => "60",
      "base03-rgb-b" => 135.0,
      "base0A-hex-b" => "3b",
      "base02-hex-r" => "8b",
      "base03-hex-b" => "87",
      "base02-rgb-b" => 146.0,
      "base07-rgb-r" => 25.0,
      "base0F-hex-r" => "bf",
      "base01-rgb-r" => 226.0,
      "base03-rgb-g" => 120.0,
      "base02-rgb-g" => 135.0,
      "base0F-hex-g" => "40",
      "base0E-hex-g" => "5a",
      "base0B-hex-r" => "2a",
      "base06-hex-r" => "26",
      "base04-hex-g" => "5f",
      "base0A-hex-g" => "6e",
      "base09-dec-g" => 0.3411764705882353,
      "base08-hex-g" => "46",
      "base09-hex-r" => "aa",
      "base0F-hex" => "bf40bf",
      "base03-dec-b" => 0.5294117647058824,
      "base09-rgb-g" => 87.0,
      "base0C-hex" => "398bc6",
      "base0E-hex-r" => "95",
      "base0D-hex-b" => "db",
      "base06-rgb-r" => 38.0,
      "base0E-rgb-b" => 231.0,
      "base0A-dec-r" => 0.6274509803921569,
      "base01-dec-g" => 0.8745098039215686,
      "base06-dec-g" => 0.13725490196078433,
      "base0E-dec-r" => 0.5843137254901961,
      "base09-dec-r" => 0.6666666666666666,
      "base05-rgb-g" => 82.0,
      "base0B-dec-g" => 0.5725490196078431,
      "base03-dec-r" => 0.49411764705882355,
      "base05-rgb-r" => 88.0,
      "base0A-dec-g" => 0.43137254901960786,
      "base00-rgb-b" => 244.0,
      "base0F-hex-b" => "bf",
      "base0B-hex-b" => "92",
      "base08-rgb-b" => 120.0,
      "base08-rgb-r" => 190.0,
      "base0C-hex-g" => "8b",
      "base0D-rgb-b" => 219.0,
      "base08-dec-b" => 0.47058823529411764,
      "scheme-slug" => "atelier-cave-light",
      "base05-hex" => "585260",
      "base02-hex-g" => "87",
      "base01-hex-g" => "df",
      "base03-dec-g" => 0.47058823529411764,
      "base0D-hex" => "576ddb",
      "base0F-dec-r" => 0.7490196078431373,
      "base04-dec-r" => 0.396078431372549,
      "base0D-dec-g" => 0.42745098039215684,
      "base00-rgb-r" => 239.0,
      "base0B-dec-b" => 0.5725490196078431,
      "base0D-hex-g" => "6d",
      "base00-dec-g" => 0.9254901960784314,
      "base09-hex-b" => "3c",
      "base03-rgb-r" => 126.0,
      "base0D-dec-r" => 0.3411764705882353,
      "base08-hex" => "be4678",
      "base0D-dec-b" => 0.8588235294117647
    }

    template = """
    # Base16 {{scheme-name}} - alacritty color config
    # {{scheme-author}}
    colors:
      # Default colors
      primary:
        background: '0x{{base00-hex}}'
        foreground: '0x{{base05-hex}}'

      # Colors the cursor will use if `custom_cursor_colors` is true
      cursor:
        text: '0x{{base00-hex}}'
        cursor: '0x{{base05-hex}}'

      # Normal colors
      normal:
        black:   '0x{{base00-hex}}'
        red:     '0x{{base08-hex}}'
        green:   '0x{{base0B-hex}}'
        yellow:  '0x{{base0A-hex}}'
        blue:    '0x{{base0D-hex}}'
        magenta: '0x{{base0E-hex}}'
        cyan:    '0x{{base0C-hex}}'
        white:   '0x{{base05-hex}}'

      # Bright colors
      bright:
        black:   '0x{{base03-hex}}'
        red:     '0x{{base09-hex}}'
        green:   '0x{{base01-hex}}'
        yellow:  '0x{{base02-hex}}'
        blue:    '0x{{base04-hex}}'
        magenta: '0x{{base06-hex}}'
        cyan:    '0x{{base0F-hex}}'
        white:   '0x{{base05-hex}}'

    """
    Mustache.render(template, data)
  end
end

and the output is not interpolated and look like this:

"# Base16 {{scheme-name}} - alacritty color config\n# {{scheme-author}}\ncolors:\n  # Default colors\n  primary:\n    background: '0x{{base00-hex}}'\n    foreground: '0x{{base05-hex}}'\n\n  # Colors the cursor will use if `custom_cursor_colors` is true\n  cursor:\n    text: '0x{{base00-hex}}'\n    cursor: '0x{{base05-hex}}'\n\n  # Normal colors\n  normal:\n    black:   '0x{{base00-hex}}'\n    red:     '0x{{base08-hex}}'\n    green:   '0x{{base0B-hex}}'\n    yellow:  '0x{{base0A-hex}}'\n    blue:    '0x{{base0D-hex}}'\n    magenta: '0x{{base0E-hex}}'\n    cyan:    '0x{{base0C-hex}}'\n    white:   '0x{{base05-hex}}'\n\n  # Bright colors\n  bright:\n    black:   '0x{{base03-hex}}'\n    red:     '0x{{base09-hex}}'\n    green:   '0x{{base01-hex}}'\n    yellow:  '0x{{base02-hex}}'\n    blue:    '0x{{base04-hex}}'\n    magenta: '0x{{base06-hex}}'\n    cyan:    '0x{{base0F-hex}}'\n    white:   '0x{{base05-hex}}'\n\n"

(I'm on version 0.3.1 this time)

obahareth added a commit to tinted-theming/base16-builder-elixir that referenced this issue Sep 4, 2017
Mustache.ex rendering is failing due to an issue with it:
schultyy/Mustache.ex#12
@space-pope
Copy link
Contributor

space-pope commented Oct 5, 2017

I know this is about a month late, but it's failing because - is an invalid character for a variable in this Mustache library. I can't find any indication of valid/invalid characters in the original Mustache spec, but for Elixir it makes sense to forbid this character since it's forbidden in (unquoted) atoms. If you replace all the -s with _, rendering works.

@obahareth
Copy link
Contributor Author

I actually switched to bbmustache (an Erlang library) and stopped having issues. I don’t really know much about the original Mustache spec, but bbmustache worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants