npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vut2ts

v0.1.0-test

Published

vue template to es6 string

Downloads

10

Readme

vue template to es6 string

install

npm i vut2ts -g

use

# single file
vut2ts ./src/demo.vue
# directory
vut2ts ./src

demo

  • 1 Demo.vue
 <template>
  <ul>
    <li v-for="item in houseList" class="houseItem" :class="{'xixi':item.id==123}">
      <h1 :houseId="item.id">{{ item.title }}</h1>
      <img v-if="item.img" :src="item.img">
    </li>
  </ul>
</template>

<script lang="ts">
export class House {
  img: string
  title: string
  id: number
}

export default {
  setup(ctx, houseList: House[]) {
    return {houseList};
  },
};
</script>
  • 2 compile (Demo.vue => Demo.ts)
vut2ts ./demo.vue
  • 3 Demo.ts
let fun = new Function("str", "data", `return (function (str, data) {var tmpData=data||{}; var tmp=""; with (tmpData) { try { tmp = eval(str); } catch (e) { console.warn(str +"not exits in data","\\n",new Error(e)); } } return tmp; } )(str, data);`)

export class House {
    img: string
    title: string
    id: number
}

const _tmp = {
    setup(ctx, houseList: House[]) {
        return {houseList};
    },
};

export default {
    expData: fun,
    setup(ctx, houseList: House[]) {
        let data = {}
        if (typeof _tmp["data"] == "function") {
            data = _tmp["data"]();
        }
        let methods = {}
        if (typeof _tmp["methods"] == "object") {
            methods = _tmp["methods"]
        }
        // @ts-ignore
        let setupData = _tmp.setup(...arguments);
        Object.assign(this, data, setupData, methods);
    },
    toString() {
        let str = `<ul>${(() => {
            var str = "";
            let _tmpItem;
            if (this['item']) {
                _tmpItem = this['item']
            }
            this.expData('houseList', this).forEach(item => {
                this['item'] = item;
                str += `<li class="${(this.expData('true', this) ? 'houseItem' : '') + ' ' + (this.expData('item.id==123', this) ? '"xixi"' : '')}"><h1 houseId="${this.expData('item.id', this)}">${this.expData('item.title', this)}</h1>
      ${(() => {
                    if (this.expData('item.img', this)) {
                        return `<img src="${this.expData('item.img', this)}"/>`
                    }
                    return ''
                })()}

    </li>` });
            this['item'] = _tmpItem;
            return str
        })()}
  </ul>
`
        return str
    }
};
  • 4 use Demo.ts
// test.ts
import {House} from "./Demo";
import Demo2 from "./Demo";

const data: House[] = [
    {
        img: "http://xxx.com/a.png",
        title: "hello word",
        id: 123
    },
    {
        img: "http://xxx.com/b.png",
        title: "nice vut2ts",
        id: 456
    }
]
Demo2.setup(null, data);
let str = Demo2.toString();
console.log(str)

output

<ul>
    <li class="houseItem xixi"><h1 houseId="123">hello word</h1>
        <img src="http://xxx.com/a.png"/>
    </li>
    <li class="houseItem"><h1 houseId="456">nice vut2ts</h1>
        <img src="http://xxx.com/b.png"/>
    </li>
</ul>