Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
feat: content type for joining
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Nov 24, 2020
1 parent 97f13df commit dddc6b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ It should be noted that Lucia should not be implemented in all use cases. Lucia

- [Vue](https://github.com/vuejs/vue) - Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
- [Alpine](https://github.com/alpinejs/alpine) - A rugged, minimal framework for composing JavaScript behavior in your markup.
- [Stimulus](https://github.com/stimulusjs/stimulus) - A modest JavaScript framework for the HTML you already have.
- [Remake](https://github.com/remake/remake-cli) - Create interactive web apps with just HTML.
- [Stimulus](https://github.com/stimulusjs/stimulus) - A modest JavaScript framework for the HTML you already have.
- [Mavo](https://github.com/mavoweb/mavo) - Create web applications entirely by writing HTML and CSS!

## Contributing
Expand Down
8 changes: 5 additions & 3 deletions src/directives/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { createApp } from '../index';
import { DirectiveArgs } from './IDirectiveArgs';

export const joinDirective = ({ el, value, view }: DirectiveArgs) => {
const [array, delimiter] = value.split('by ');
const [array, contentType, delimiter] = value.split(/ as | by /);
const out = compute(array, { $view: view, $el: el });

// By default
const accessProp = contentType === 'text' ? 'innerText' : 'innerHTML';
if (out !== undefined) {
el.innerHTML = out.join(delimiter || '');
el[accessProp] = out.join(delimiter || '');
} else {
el.innerHTML = array.join(delimiter || '');
el[accessProp] = array.join(delimiter || '');
}

// Create shallow nested Lucia app
Expand Down
2 changes: 1 addition & 1 deletion src/utils/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const computeProperties = (
// view keys as global properties. Accept normal eval if this.$view is not
// provided in the data parameter
return new Function(
`with(${Object.keys(data).length === 0 ? 'this' : 'this.$view'}) {${
`with(${Object.keys(data).length === 0 ? 'this' : 'this.$view'}){${
// Return if requested
returnable ? `return ${expression}` : expression
}}`
Expand Down

0 comments on commit dddc6b6

Please sign in to comment.