Vue

by khamer

HTML

<main>
  <pick>
    hello there
    what is going on
    cheese
  </pick>
</main>

Vue

Vue.component('pick', {
	render(createElement) {
  	let text = this.$scopedSlots.default().map(({text}) =>text).join();
    
    let phrases = [...this.$scopedSlots.default().map(({text}) => text)
    	.join()
      .matchAll(/(?<=^\s*)([^\s].*?)(?=\s*$)/gm)]
      .map(([match]) => match);
      
    console.log(phrases);
    
  	return createElement('div', phrases[Math.floor(Math.random() * phrases.length)]);
  }
})

new Vue({
  el: "main",
})