(Classic) emit()

Engine Compatibility

emit is not supported by the Node engine.

emit <javascript>

Directly after the declaration block, KRL programs can contain a single, optional emit statement.

The value following the emit statement is put into the Javascript generated from the KRL program immediately after the variable declarations and before any actions. This allows Javascript to be inserted into the program to modify the values of any variables.

emit << 
	console.log('Hello world');
>>;

The following ruleset shows emit() being used

ruleset a1299x168 {
	meta {
		name "emit example"
		author "nathan cerny"
		logging off
	}
	dispatch {
		// domain "exampley.com"
	}

	rule emit_example {
		select when pageview ".*" setting ()
        {
	        emit <<
                $K('h1').append('Hello World');
            >>;
        }
	}
}

The following demonstrates the preceding rule:

Copyright Picolabs | Licensed under Creative Commons.