Skip to content

Couldn't succeed in rendering general diff as text #7

@amb26

Description

@amb26

I tried following the tutorial instructions at https://github.com/fluid-project/fluid-diff/blob/main/docs/tutorial.md but couldn't get a diff to render.

Some problems are

  • The tutorial text doesn't explain what the first argument to renderer.render actually is - I inferred that it is meant to be the stem name of one of the "pages" in a directory like https://github.com/fluid-project/fluid-diff/tree/main/src/templates/pages but the arguments should be explained in a docs file as well as a tutorial.

  • It's unclear what the "diff-text" template at https://github.com/fluid-project/fluid-diff/blob/main/src/templates/pages/diff-text.handlebars actually does. I was hoping that given any kind of diff between compound structures, it would render just those parts which had been changed. It's not clear that it does do this, or at least, I get no output from it on my diff.

  • The configuration of the helpers is unclear. I'm not really sure why I need the isDiffArray helper, or indeed any of the others - if I am likely to need any or all of them, shouldn't all 4 of the ones that are implemented be provided by default?

The invocation I use is diffRenderer.render("diff-text", diff), with all the other details exactly as they are in the tutorial.

Here is the beginning of my diff structure, which also seems to be unnecessarily large - the only real change is that the id "qunit-header" has been removed, but instead fluid-diff considers that the entire structure has been removed and added.

    {
      "type": "removed",
      "arrayValue": [
        {
          "tagName": "body",
          "childNodes": [
            {
              "tagName": "h1",
              "attrs": {
                "id": "qunit-header"
              },
              "text": "Renderer Component Rewriting Test"
            },
            {
              "tagName": "div",
              "attrs": {},
              "childNodes": [
                {
                  "tagName": "input",
                  "attrs": {
                    "class": "renderer-test-field",
                    "type": "text"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "type": "added",
      "arrayValue": [
        {
          "tagName": "body",
          "childNodes": [
            {
              "tagName": "h1",
              "text": "Renderer Component Rewriting Test"
            },
            {
              "tagName": "div",
              "attrs": {},
              "childNodes": [
                {
                  "tagName": "input",
                  "attrs": {
                    "class": "renderer-test-field",
                    "type": "text"
                  }
                }
              ]
            }
          ]
        }
      ]
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions