Giter Club home page Giter Club logo

Comments (7)

assemblebot avatar assemblebot commented on June 3, 2024

@mootari Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

from assemble-loader.

jonschlinkert avatar jonschlinkert commented on June 3, 2024

The check here might make more sense. If .contents exists, then .content should exist as well since the properties are synced. If .contents does not exist, then it seems like we wouldn't want to check for .content, since the existence of only one of those properties indicates it's not a valid View. thoughts? @doowb?

Some of this logic was done as we were still building the API and learning about what we were creating. Thanks for creating issues, it's much appreciated.

from assemble-loader.

mootari avatar mootari commented on June 3, 2024

Not sure if this is relevant, but utils.normalizeContent() in load-templates checks for both content and contents:
https://github.com/jonschlinkert/load-templates/blob/995ccaf1955652ad3401d8457f331917b308b110/utils.js#L36-L47

from assemble-loader.

doowb avatar doowb commented on June 3, 2024

This specific isView method is only used in this library to determine if a passed in object looks like a view or an options object. Another piece of code handles normalizing and "syncing" the content and contents properties later so I think that we should add a check for .content in this specific method.

@mootari if you'd like to do a PR to update this piece of code, that would be awesome! I think you pointed out in another issue that some of these use hasOwnProperty and some don't. I think this should be updated to either using .hasOwnProperty or typeof obj.property === 'undefined'.

Also, if you have ideas on consolidating the places where this code is duplicated into a single module that can be reused that would be great! Thanks for getting into the code and opening these issues, it really helps.

from assemble-loader.

jonschlinkert avatar jonschlinkert commented on June 3, 2024

think this should be updated to either using .hasOwnProperty or typeof obj.property === 'undefined'.

We don't want to use typeof obj.property === 'undefined' since it's possible for a property to be defined with an undefined value. I believe .contents and .content are both enumerable so .hasOwnProperty() should be find. Otherwise we should use !(key in view).

from assemble-loader.

mootari avatar mootari commented on June 3, 2024

I did a quick search through assemble's dependencies. The following places call .isView():

  1. if (utils.isView(options)) options = {};
  2. https://github.com/jonschlinkert/load-templates/blob/995ccaf1955652ad3401d8457f331917b308b110/index.js#L60
  3. https://github.com/jonschlinkert/load-templates/blob/995ccaf1955652ad3401d8457f331917b308b110/index.js#L69
  4. https://github.com/jonschlinkert/load-templates/blob/995ccaf1955652ad3401d8457f331917b308b110/index.js#L180
  5. https://github.com/jonschlinkert/load-templates/blob/995ccaf1955652ad3401d8457f331917b308b110/index.js#L198
  6. https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/views.js#L259

from assemble-loader.

mootari avatar mootari commented on June 3, 2024
  1. Looks like overloading for the options param, but the intention is not clear to me.
  2. For an array of templates, used to delegate each to either .addView() and .load()
  3. Again, looks like overloading for the options param (gate to either .addView() or .globViews())
  4. Overloads for the options param.
  5. Initializes path and key prior to passing off to .addView()
  6. Optional view argument, not clear where/when used.

from assemble-loader.

Related Issues (1)

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.