Giter Club home page Giter Club logo

Comments (5)

thanethomson avatar thanethomson commented on May 30, 2024 1

As you mentioned on #29, this is a direct result of not explicitly specifying the -t mustache parameter. There's unfortunately no easy way for the tool to infer which templating language you want to use.

The makeVariableTrackerProxy function is ultimately a hack (and an ugly one at that), and one that should eventually rather be replaced by proper parsing of the template to expose its variables.

In the meantime, it should suffice to just catch this type of error during the execution of the new command and add a hint to the effect of: (did you perhaps forget to specify the template type?).

from themis-contract.

shonfeder avatar shonfeder commented on May 30, 2024

Perhaps this bit of code in https://github.com/informalsystems/neat-contract/tree/master/src/shared/template-helpers.ts is responsible:

Seems likely to be originating in this function:

const makeVariableTrackerProxy = (parentObj: object, parents: string[], trackedVars: Map<string, any>): object => {
  return new Proxy(parentObj, {
    get: (target, name) => {
      if (typeof name === 'symbol') {
        return ''
      }
      if (name === 'toHTML') {
        return (): string => ''
      }
      const varName = String(name)
      logger.debug(`Found potential template variable: ${varName}`)
      trackVariable(trackedVars, parents, varName)
      return makeVariableTrackerProxy(target, [...parents, varName], trackedVars)
    },
  })
}

Both due to the log locations, and due to the fact this function can return either a string or a function string -> string. At some point, a consumer of the values from this function is getting that empty string out and trying to apply it as a function

from themis-contract.

shonfeder avatar shonfeder commented on May 30, 2024

Cool, I'll add that fix when I get a moment. Thanks!

from themis-contract.

shonfeder avatar shonfeder commented on May 30, 2024

What about changing the default templating language to be mustache too? It seems to me preferable, both because we are using it more pervasively, and because it's more constrained.

from themis-contract.

thanethomson avatar thanethomson commented on May 30, 2024

Sure, let's make Mustache the default 👍 I'll open an issue.

from themis-contract.

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.