Giter Club home page Giter Club logo

elements's Introduction

๐Ÿ‘‹ Oh look, a visitor!

Welcome to my GitHub profile

This is the place my coding projects are stored. Besides lecturing mathematics, I really enjoy to develop web applications using self-made libraries like pwa, colony and idb. Have a look around!

elements's People

Contributors

ljans avatar

Watchers

 avatar  avatar

elements's Issues

Recurring names in nested context

Situation

Imagine the following dataset:

{
	value: '1st level value', 
	context: {
		value: '2nd level value'
	}
}

Applied on this template:

<p>{{value}}</p>
{{#context}}
	<p>{{value}}</p>
{{/context}}

This output is produced:

1st level value
1st level value

Reasons

That happens, because the 'value' of the global context is rendered in the whole template before the context section gets rendered due to the order of processing in renderRecursive. So after renderVariables, the template looks like this:

<p>1st level value</p>
{{#context}}
	<p>1st level value</p>
{{/context}}

Evaluation

An advantage of this behavior is, that static values referring to an upper context inside big lists only have to be rendered once. The disadvantage is, that names can't be re-assigned inside sections.

Solutions

Option 1

Change order of processing in renderRecursive. This has to be checked for undesired side-effects.

Option 2

Introduce backwards-context with a double-dot like this:

{{#context}}
	<p>{{value}}</p>
	<p>{{..value}}</p>
{{/context}}

This should then produce the following output:

2nd level value
1st level value

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.