Piotr Sikora - Logo - Automatyzacja procesów | AI | JavaScript | Front End | Team Leader
  • Home
  • Services
    • Process Automation
    • AI for Lawyers
    • Holded Automation
  • Blog
  • Quotes
  • Contact
PL/EN

Vue.js ScreenshotMaker Part 2: Using Jade & Variables

  • Home
  • Blog
  • Vue.js ScreenshotMaker Part 2: Using Jade & Variables
Vue.js ScreenshotMaker Part 2: Using Jade & Variables

By Piotr Sikora

  • javascript

  • 3 min read

Table of Contents

  • Changes in variables
  • Usage of JADE instead raw HTML

Each project needs evolution. After a comment by Peter van Meijgaard (https://github.com/petervmeijgaard) in previous post (http://fedojo.com/vue-js-first-look-and-test/) Ive made a few changes.

Changes in variables

Previously:

makeScreenshot: function(e) {
                    this.$set('form', false);
                    this.$set('inprogresss', true);

                    Vue.http.get('http://localhost:8888/screenshot?url='+this.url).then((response) => {
                        var res = JSON.parse(response.body);
                        this.$set('success', true);
                        this.$set('inprogresss', false);
                    }, (response) => {
                        this.$set('error', true);
                        this.$set('inprogresss', false);
                    });
}

Current:

methods: {
                makeScreenshot: function(e) {
                    this.form = false;
                    this.inprogress = true;

                    Vue.http.get('http://localhost:8888/screenshot?url='+this.url).then((response) => {
                        var res = JSON.parse(response.body);
                        this.success = true;
                        this.inprogress = false;
                    }, (response) => {
                        this.error = true;
                        this.inprogress = false;
                    });
                }
            }

So the changes are visible in each call to variables defined in data function:

data(){
                return {
                    form: true,
                    error: false,
                    success: false,
                    inprogress: false,
                    url: ''
                }
},

It doesnt need usage:

this.$set('success', true);

It can be done with:

this.success = true;

Usage of JADE instead raw HTML

I love preprocessors and wished to use JADE templating. It is possible in Vue.js to define template in .vue file as a JADE. To do that you need to add JADE to your node_modules:

<pre class="line-numbers"><code class="language-javascript">sudo npm i jade --save
</code></pre>

Now you can bring your JADE code in template section:

<template>
    p This is screenshotmaker!
    div(v-if="form")
        input(v-model="url", placeholder="URL")
        button(v-on:click="makeScreenshot") Make screenshot
    div(v-if="error")
        p Error
    div(v-if="success")
        p Screenshot done!
    div(v-if="inprogress")
        p In progress
</template>

<script lang="babel">
    import Vue from 'vue';

    export default{
        data(){
            return {
                form: true,
                error: false,
                success: false,
                inprogress: false,
                url: ''
            }
        },
        methods: {
            makeScreenshot: function (e) {
                this.form = false;
                this.inprogress = true;

                Vue.http.get('http://localhost:8888/screenshot?url=' + this.url).then((response) => {
                    var res = JSON.parse(response.body);
                    this.success = true;
                    this.inprogress = false;
                }, (response) => {
                    this.error = true;
                    this.inprogress = false;
                });
            }
        }
    }

Changes are visible in https://github.com/fedojo/screenshot-maker-fe-vue/tree/v0.2-jade

Tags:

    #jade

    #pug

    #screenshot

    #screenshot-maker

    #vuejs

Comments

Categories

after-hours(1)AI(9)ai-en(1)angular(4)automatic-tests(1)Automation(2)cryptography(1)css(8)CyberSecurity(2)Development(7)DevOps(1)events(3)javascript(11)n8n(31)ollama(1)security(2)seo(1)

Recent Posts

Prompting workshop at IdeaLab in Kielce — participants working at a laptop

AI

Effective Prompting — a Workshop for Young People at IdeaLab in Kielce

OCR in n8n for Multiple Receipts and Invoices at Once — Saving to Google Sheets

n8n

OCR in n8n for Multiple Receipts and Invoices at Once — Saving to Google Sheets

Checking Variable Values in n8n: IF vs SWITCH

n8n

Checking Variable Values in n8n: IF vs SWITCH

Automate Your Gmail with n8n — AI-Generated Reply Drafts with an LLM

n8n

Automate Your Gmail with n8n — AI-Generated Reply Drafts with an LLM

n8n: ZPE Lesson Generator — from URL to a Complete Lesson in 90 Seconds

n8n

n8n: ZPE Lesson Generator — from URL to a Complete Lesson in 90 Seconds

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates
View Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO

Tags

activepiecesafter-hoursahrefsaiai agentsai automationAI cost reductionai in educationai securityangularanonymizationantigravityapiAqua Securityarcade-gamesarchitectureautomationbackendbest-practicesbielik
“Everything we hear is an opinion, not a fact”
Marcus Aurelius
View more quotes

Similar Articles

Discover more related content

Pug Video Course: Master Template Engine

Pug Video Course: Master Template Engine

Announcing my free video course on the Pug template engine, from the basics of tags and attributes to advanced concepts like conditionals and mixins.

Vue, Vue Router, Vuex with TypeScript - Part 1

Vue, Vue Router, Vuex with TypeScript - Part 1

A beginner-friendly guide to starting a Vue.js project with Vue Router and Vuex using TypeScript, from Vue CLI setup to building a simple CRUD app.

ScreenshotMaker with Vue.js: First Look & HTTP

ScreenshotMaker with Vue.js: First Look & HTTP

A first look at Vue.js building a ScreenshotMaker app: using the CLI, vue-resource for HTTP GET requests, a simple component and basic client-side routing.

Piotr Sikora | ai | n8n | javascript | python

Let's get to know each other!

Get in touch with me
Piotr Sikora | Process Automation  | AI Implementation 🤖 | Technology Consulting
Quick links
  • Home
  • Blog
  • Contact
Contact
  • piotr.sikora.ck@gmail.com
  • +48 505 684 661

© Piotr Sikora 2026 | All Rights Reserved